【发布时间】:2015-11-03 12:58:03
【问题描述】:
我的解决方案中有两个项目,一个是简单的mvc项目,另一个是web api。我使用了Entity Framework。我还使用了 asp.net 身份,它生成了在 AspNetUsers 表中有很多列的本地数据库。现在我想从 AspNetUsers 表中添加和删除一些列。 我在我的项目中包含了 Migrations 文件夹,其中包含 configuration.cs 和初始 create.cs 类
CreateTable(
"dbo.AspNetUsers",
c => new
{
Id = c.String(nullable: false, maxLength: 128),
Email = c.String(maxLength: 256),
EmailConfirmed = c.Boolean(nullable: false),
PasswordHash = c.String(),
SecurityStamp = c.String(),
PhoneNumber = c.String(),
PhoneNumberConfirmed = c.Boolean(nullable: false),
TwoFactorEnabled = c.Boolean(nullable: false),
LockoutEndDateUtc = c.DateTime(),
LockoutEnabled = c.Boolean(nullable: false),
AccessFailedCount = c.Int(nullable: false),
UserName = c.String(nullable: false, maxLength: 256),
})
.PrimaryKey(t => t.Id)
.Index(t => t.UserName, unique: true, name: "UserNameIndex");
我也尝试使用包管理器控制台更新数据库,但没有任何反应。 那么如何在 AspNetUsers 表中添加另一列? 提前致谢。
【问题讨论】:
-
向
AspNetUsers实体添加新属性,然后使用add-migration命令引用coding.abel.nu/2012/03/ef-migrations-command-reference/…也引用msdn.microsoft.com/en-us/data/jj591621.aspx
标签: asp.net-mvc-4 asp.net-web-api2