public async static Task Initialize(IServiceProvider serviceProvider) { using (var context = new UnsplashContext( serviceProvider.GetRequiredService <DbContextOptions <UnsplashContext> >())) { // Look for any board games. if (await context.Users.AnyAsync()) { return; // Data was already seeded } var pwd = "012345"; AuthUtil.CreatePasswordHash(pwd, out byte[] passwordHash, out byte[] passwordSalt); context.AddRange( new User { ID = 1, Username = "******", CreatedAt = DateTime.Now, Email = "*****@*****.**", Role = UserRoles.Admin, PasswordHash = passwordHash, PasswordSalt = passwordSalt }, new User { ID = 2, Username = "******", CreatedAt = DateTime.Now, Email = "*****@*****.**", Role = UserRoles.AppUser, PasswordHash = passwordHash, PasswordSalt = passwordSalt }, new Category { ID = 1, CategoryName = "Cars", Description = "For all your automobile photos.", CreatedAt = DateTime.Now, ModifiedAt = DateTime.Now, } ); context.SaveChanges(); } }
public Repository(UnsplashContext context, ILogger <Repository <T> > log) { logger = log; Context = context; }