static void InitProjects(TnRContext context) { if (context.Projects.Any()) { return; } context.Projects.Add( new Project { Name = "Secret Project", Description = "classified", Created = DateTime.Now, Modified = DateTime.Now, }); context.Projects.Add( new Project { Name = "Undercover Project", Description = "confidential", Created = DateTime.Now, Modified = DateTime.Now, }); }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new TnRContext( serviceProvider.GetRequiredService <DbContextOptions <TnRContext> >())) { if (context.Projects.Any()) { return; } context.Projects.Add( new Project { Name = "Daily News", Description = "Newspaper of the day", Created = DateTime.Now, Modified = DateTime.Now, }); context.Projects.Add( new Project { Name = "Daily Evening News", Description = "Evening update", Created = DateTime.Now, Modified = DateTime.Now, }); context.SaveChanges(); } }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new TnRContext( serviceProvider.GetRequiredService <DbContextOptions <TnRContext> >())) { InitUsers(context); InitProjects(context); context.SaveChanges(); } }
static void InitUsers(TnRContext context) { if (context.Users.Any()) { return; } context.Users.Add( new User { Name = "Admin", Pwd = "123456" }); }