标签:
public class ApplicationContext : DbContext { public DbSet<User> Users { get; set; } public ApplicationContext() : base("ApplicationConnection") { //Database.Create(); Database.SetInitializer(new SystemInitializer()); } } public class SystemInitializer : DropCreateDatabaseIfModelChanges<ApplicationContext> { protected override void Seed(ApplicationContext context) { var user = new User() { UserName="admin", DisplayName="系统管理员", Password = "admin", Email="admintest@126.com" }; context.Users.Add(user); } }
标签:
原文地址:http://www.cnblogs.com/sky-net/p/5207127.html