MVC5 执行数据库迁移时,会生成一些默认的数据表,但是在实际的工作中。若用到的时候,难免要增添一些字段。

1.AspNetUsers 增加字段

A.打开MVC中的 IdentityModels.cs 文件,具体代码如下:

public class ApplicationUser : IdentityUser
    {
        #region 添加字段
        public string IsUser { get; set; }
        public string Tel { get; set; }
        public DateTime CreateTime { get; set; }
        public DateTime UpdateTime { get; set; }
        #endregion
        public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
        {
            // 请注意,authenticationType 必须与 CookieAuthenticationOptions.AuthenticationType 中定义的相应项匹配
            var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
            // 在此处添加自定义用户声明
            return userIdentity;
        }

   public virtual UserSetting UsersSetting { get; set; }//增加两个表用来显示用户数据

}

    public class ApplicationRole : IdentityRole
{
public ApplicationRole() : base() { }
public ApplicationRole(string name) : base(name) { }
public ApplicationRole(string name, string description)
: this(name)
{
this.Description = description;
} public string Description { get; set; }//角色表里新增加的字段
}
    public class UserSetting
{
public string Id { get; set; }
public string Theme { get; set; }
}

public class ApplicationDbContext : IdentityDbContext<ApplicationUser>

{

public ApplicationDbContext()

: base("APPDataConnection", throwIfV1Schema: false)

{         }

public static ApplicationDbContext Create()

{

return new ApplicationDbContext();

}

}

B.执行MVC 数据迁移,具体可以参考前篇博客

如何修改Id:

https://github.com/TypecastException/AspNet-Identity-2-With-Integer-Keys/blob/master/IdentitySample/Models/IdentityModels.cs

http://www.myexception.cn/vc-mfc/2000098.html

ASP.NET MVC5 之 AspNetUsers 表增加字段的更多相关文章

  1. 家长-Parents表增加字段Token,Gender,Email,Portrait

    家长-Parents表增加字段Token,Gender,Email,Portrait ) ) ) )

  2. oracle删除表字段和oracle表增加字段

    这篇文章主要介绍了oracle表增加字段.删除表字段修改表字段的使用方法,大家参考使用吧   添加字段的语法:alter table tablename add (column datatype [d ...

  3. 实战-130W表增加字段耗时

    工作需要对130W的表增加字段,因为是操作线上数据库,所以提前在本地调查下耗时. 首先建表: CREATE TABLE `alter_cloumn_test` ( `id` int(11) unsig ...

  4. django 重写User表增加字段设置

    models中: from django.contrib.auth.models import AbstractUser lass User(AbstractUser): mobile = model ...

  5. MySQL 给已存在的数据表 增加字段和注释

    MySQL 给已存在的数据表 增加字段和注释 问题描述 在开发一个系统的过程中,经常会遇到随着系统服务功能的扩展,或者服务之间的关联,需要适当的修改原有的表结构,比如,增加一些必要的字段. 示例:在已 ...

  6. MySQL中大数据表增加字段,增加索引实现

    MySQL中大数据表增加字段,通过增加索引实现 普通的添加字段sql ALTER TABLE `table_name` ADD COLUMN `num` int(10) NOT NULL DEFAUL ...

  7. 修改表增加字段默认值default

    对个生产库的表增加1个字段.字段类型是INT型, 表数据有2千万条, alter table table_name add xxoo number(4) default  0 ; 因此 不仅要修改字典 ...

  8. sql 创建表、删除表 增加字段 删除字段操作

    下面是Sql Server 和 Access 操作数据库结构的常用Sql,希望对你有所帮助. 新建表:create table [表名]([自动编号字段] int IDENTITY (1,1) PRI ...

  9. SqlServer2012-创建表、删除表 增加字段 删除字段操作

    新建表:create table [表名]([自动编号字段] int IDENTITY (1,1) PRIMARY KEY ,[字段1] nVarChar(50) default \'默认值\' nu ...

随机推荐

  1. linux time-统计给定命令所花费的总时间

    推荐:更多linux 性能监测与优化 关注:linux命令大全 time命令用于统计给定命令所花费的总时间. 语法 time(参数) 参数 指令:指定需要运行的额指令及其参数. 实例 当测试一个程序或 ...

  2. sublime3注册码

    TwitterInc User License EA7E 1D77F72E 390CDD93 4DCBA022 FAF60790 61AA12C0 A37081C5 D0316412 4584D136 ...

  3. String类的获取功能

    /* * String类的获取功能: * int length():获取字符串的长度,其实也就是字符个数 * char charAt(int index):获取指定索引处的字符 * int index ...

  4. 浅谈href=与href=javascript_void(0)的区别

    "#"包含了一个位置信息.默认的锚点是#top 也就是网页的顶端.而javascript:void(0)  仅仅表示一个死链接,这就是为什么有的时候页面很长,浏览链接明明是#可是跳 ...

  5. 【Codeforces 924C】Riverside Curio

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 设第i天总共的线数为t[i] 水平线上线数为m[i]是固定的 水平线下的线数设为d[i] 则d[i]+m[i]+1=t[i] 也就是说问题可以 ...

  6. pyhthon第一个小脚本——文件备份

    先说说这个脚本的作用:对指定路径的文件进行压缩备份到另一个指定的路径,并且压缩文件的文件名用当时的日期+时间命名. 先是对着<简明Python教程>上的代码敲的,一堆错误,书上给的是lin ...

  7. Codeforces Round #240 (Div. 2) C Mashmokh and Numbers

    , a2, ..., an such that his boss will score exactly k points. Also Mashmokh can't memorize too huge ...

  8. Luogu P1257 平面上的最接近点对 暴力

    这道题数据不大 两点距离用勾股定理求 #include<iostream> #include<cmath> using namespace std; struct node{ ...

  9. N的倍数

    题目来源: Ural 1302 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 一个长度为N的数组A,从A中选出若干个数,使得这些数的和是N的倍数. 例如:N = ...

  10. Linux 使用pwgen命令创建随机密码

    https://blog.csdn.net/fdipzone/article/details/73864598 http://www.netkou.com/?post=155