ASP.NET MVC5 之 AspNetUsers 表增加字段
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 表增加字段的更多相关文章
- 家长-Parents表增加字段Token,Gender,Email,Portrait
家长-Parents表增加字段Token,Gender,Email,Portrait ) ) ) )
- oracle删除表字段和oracle表增加字段
这篇文章主要介绍了oracle表增加字段.删除表字段修改表字段的使用方法,大家参考使用吧 添加字段的语法:alter table tablename add (column datatype [d ...
- 实战-130W表增加字段耗时
工作需要对130W的表增加字段,因为是操作线上数据库,所以提前在本地调查下耗时. 首先建表: CREATE TABLE `alter_cloumn_test` ( `id` int(11) unsig ...
- django 重写User表增加字段设置
models中: from django.contrib.auth.models import AbstractUser lass User(AbstractUser): mobile = model ...
- MySQL 给已存在的数据表 增加字段和注释
MySQL 给已存在的数据表 增加字段和注释 问题描述 在开发一个系统的过程中,经常会遇到随着系统服务功能的扩展,或者服务之间的关联,需要适当的修改原有的表结构,比如,增加一些必要的字段. 示例:在已 ...
- MySQL中大数据表增加字段,增加索引实现
MySQL中大数据表增加字段,通过增加索引实现 普通的添加字段sql ALTER TABLE `table_name` ADD COLUMN `num` int(10) NOT NULL DEFAUL ...
- 修改表增加字段默认值default
对个生产库的表增加1个字段.字段类型是INT型, 表数据有2千万条, alter table table_name add xxoo number(4) default 0 ; 因此 不仅要修改字典 ...
- sql 创建表、删除表 增加字段 删除字段操作
下面是Sql Server 和 Access 操作数据库结构的常用Sql,希望对你有所帮助. 新建表:create table [表名]([自动编号字段] int IDENTITY (1,1) PRI ...
- SqlServer2012-创建表、删除表 增加字段 删除字段操作
新建表:create table [表名]([自动编号字段] int IDENTITY (1,1) PRIMARY KEY ,[字段1] nVarChar(50) default \'默认值\' nu ...
随机推荐
- Jmeter学习笔记之逻辑控制器-Runtime Controller
文章目录 Runtime Controller介绍 Runtime Controller 编辑界面 Once Only Controller介绍 Once Only Controller 配置界面 O ...
- intel compiler的表现
好久没弄这个东西,今天突然想试下,代码没写完,以后补. #include <stdio.h> #include <stdlib.h> #include <time.h&g ...
- HDU 1228 字符串到数字的转化
一道水题,练练字符串的输入输出 #include <cstdio> #include <cstring> using namespace std; ] , s2[]; int ...
- apt-get使用指南
最近频繁使用apt-cache show(查看软件包详细信息)与apt-cache search(搜寻具体软件包确切名称)命令,深感方便与功能强大.现将一些apt-get相关命令做一个简单的收集: a ...
- Python函数基础---参数、变量
函数:指将一组语句的集合通过一个名字(函数名)封装起来,要想执行这个函数,只需调用其函数名即可. def sayhi( ): # 函数名 print('hello world') sayhi( ) # ...
- 【驱动开发】file_operations ---linux 2.6.30
路径: linux-2.6.30/include/linux/fs.h struct file_operations { struct module *owner; loff_t ...
- GIS服务器开发资源文档
JAVA开发gis后台服务可以参照此文学习,持续跟新... 几何基础类库 代表: JTS(Java), GEOS(C++), Shapely(Python) JTS封装了点.线等等对象 数据源实现 ...
- Ext.data.JsonStore的使用
最近在维护一个Ext.js写的贷前服务系统,Ext.data.JsonStore相当于前台页面的一个数据仓库,负责保存后台传过来的Json数据,具体用法如下: var store12=new Ext. ...
- Pivotal-tc-Server与Tomcat区别
Pivotal-tc-Server之前叫做SpringSource tc Server,包含三个版本分别是:Spring版.标准版和开发版,但其中只有开发版是免费的.比如在STS中包含的版本就是开发板 ...
- Jsp中EL表达式的使用
林炳文Evankaka原创作品.转载请注明出处http://blog.csdn.net/evankaka 1.什么是EL EL是JSP表达式语言,全称是ExpressionLang ...