我正在使用我专门为测试它而构建的新MVC5应用程序。
我有两个 db上下文。 configuration.cs
的{{1}}如下:
ApplicationDbContext
上面的代码不应该是用户的数据库吗?可悲的是它没有!当我查询using FB.DOMAIN.Authentication;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using System.Data.Entity.Migrations;
namespace FB.DAL.Migrations.ApplicationDbContext
{
internal sealed class Configuration : DbMigrationsConfiguration<DataContexts.ApplicationDbContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = false;
MigrationsDirectory = @"Migrations\ApplicationDbContext";
}
protected override void Seed(DataContexts.ApplicationDbContext context)
{
var roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(context));
var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(context));
if (!roleManager.RoleExists("Admin"))
{
roleManager.Create(new IdentityRole("Admin"));
}
var user = new ApplicationUser { UserName = "james@world.com" };
if (userManager.FindByName("james@world.com") != null) return;
var result = userManager.Create(user, "Password123!");
if (result.Succeeded)
{
userManager.AddToRole(user.Id, "Admin");
}
}
}
}
表时,它是空白的!
我做错了什么? :(