Old*_*zer 10 asp.net-mvc entity-framework ef-code-first asp.net-identity asp.net-identity-2
我正在使用VS 2013附带的标准MVC模板.它有一个简洁的会员提供商,使外部登录(谷歌,Facebook等)变得轻而易举.还有关于如何扩展IdentityUser模型以添加新属性(如出生日期)的教程.
我想在已编码的数据库上下文中添加更多(我的应用程序)表,以便享受相同的代码首次迁移功能.我该怎么做?当前的db上下文定义如下:
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("DefaultConnection", throwIfV1Schema: false)
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
Run Code Online (Sandbox Code Playgroud)
Naz*_*ain 23
你正在使用asp.net MVC5身份2然后在IdentityModels.cs中已经有ApplicationDbContext.所以你可以像这样添加表(DbSet).
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("ApplicationDbContext", throwIfV1Schema: false)
{
}
public DbSet<Department> Departments { get; set; }
public DbSet<Student> Students { get; set; }
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10120 次 |
| 最近记录: |