public UnitOfWork(KCDBContext dbContext) { _dbContext = dbContext; }
public static async Task SeedAsync(KCDBContext db) { try { if (!db.Users.Any()) { var newUser = new User { UserName = "******", RealName = "Admin", Phone = "18611838132", Email = "*****@*****.**", AddTime = DateTime.Now, UserPassword = "******" }; db.Add(newUser); var model1 = new Module { ModuleName="系统管理", ModuleUrl="", ModuleSortIndex=1, ModuleDesc= "系统管理", ModuleUse = true, Icon= "fa fa-gear", Children = new [] { new Module() { ModuleName="模块管理", ModuleUrl="/Modules", ModuleSortIndex=1, ModuleDesc= "模块管理", ModuleUse = true, Icon="" }, new Module() { ModuleName="用户管理", ModuleUrl="/Users", ModuleSortIndex=2, ModuleDesc= "用户管理", ModuleUse = true, Icon="" }, new Module() { ModuleName="角色管理", ModuleUrl="/Roles", ModuleSortIndex=3, ModuleDesc= "角色管理", ModuleUse = true, Icon="" }, new Module() { ModuleName="字典管理", ModuleUrl="/BackEnums", ModuleSortIndex=4, ModuleDesc= "字典管理", ModuleUse = true, Icon="" } } }; db.Add(model1); await db.SaveChangesAsync(); } } catch (Exception e) { Console.WriteLine(e); throw; } }