private void SeedDataIdentity(BankAppDataContext context, UserManager <IdentityUser> userManager) { AddRoleIfNotExists(context, "Admin"); AddRoleIfNotExists(context, "Cashier"); AddIfNotExists(userManager, "*****@*****.**", "Cashier"); AddIfNotExists(userManager, "*****@*****.**", "Admin"); }
private void AddRoleIfNotExists(BankAppDataContext context, string role) { if (context.Roles.Any(r => r.Name == role)) { return; } context.Roles.Add(new IdentityRole { Name = role, NormalizedName = role }); context.SaveChanges(); }
private void SeedData(BankAppDataContext context) { if (!context.BatchStatus.Any(r => r.LastId > 0)) { context.BatchStatus.Add(new BatchStatus { LastId = 1 }); } if (context.MobileAppUsers.Count() == 0) { context.MobileAppUsers.Add(new MobileAppUsers { Username = "******", Password = "******", CustomerId = 1 }); context.MobileAppUsers.Add(new MobileAppUsers { Username = "******", Password = "******", CustomerId = 2 }); context.MobileAppUsers.Add(new MobileAppUsers { Username = "******", Password = "******", CustomerId = 3 }); context.MobileAppUsers.Add(new MobileAppUsers { Username = "******", Password = "******", CustomerId = 4 }); context.MobileAppUsers.Add(new MobileAppUsers { Username = "******", Password = "******", CustomerId = 5 }); } context.SaveChanges(); }
public void InitializeBankApp(BankAppDataContext context, UserManager <IdentityUser> userManager) { context.Database.Migrate(); SeedDataIdentity(context, userManager); SeedData(context); }
public void Initialize(BankAppDataContext context) { //context.Database.EnsureCreated(); context.Database.Migrate(); SeedData(context); }