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. jieba的基本使用

    目录 1.分词 2.添加自定义词典 3.关键词提取 4.词性标注 jieba 是一款优秀的 Python 第三方中文分词库,可以使用 pip install jieba / pip3 install ...

  2. ubuntu root用户登陆

    sudo vi /etc/lightdm/lightdm.conf   (如果没有该文件则创建,内容如下) [SeatDefaults] user-session=ubuntu greeter-ses ...

  3. change legend layout from 'vertical' to 'horizontal' in Paraview

    ********** # get color legend/bar for 'vLUT' in view 'renderView1'vLUTColorBar = GetScalarBar(vLUT, ...

  4. Maven_在Eclipse中执行Maven命令

  5. java中List遍历删除元素-----不能直接 list.remove()

    https://blog.csdn.net/github_2011/article/details/54927531 这是List接口中的方法,List集合调用此方法可以得到一个迭代器对象(Itera ...

  6. HDU 1159 LCS最长公共子序列

    #include <cstdio> #include <cstring> using namespace std; ; #define max(a,b) a>b?a:b ...

  7. CODEVS1222 信与信封问题 (匈牙利算法)

    先做一遍匈牙利算法.对于已经匹配的边,如果删去之后还能最大匹配数增加,则不符合要求. 一遍匈牙利算法是O(n^3)的,对于每一条边做n次,每次O(n^2),总的复杂度是O(n^3). 注意:不要忘记输 ...

  8. [bzoj1833][ZJOI2010]数字计数(数位DP)

    题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1833 分析:简单的数位DP f[i][j][k]表示在i位数.最高位j的所有数字中k的 ...

  9. 马悦:《Linux内核分析》MOOC课程

    http://www.cnblogs.com/20135235my/p/5237267.html

  10. RMAN RECOVERY

    Data Recovery Advisor The health monitor and the ADR The capabilities and limitations of DRA using t ...