public void Execute(IApplicationBuilder applicationBuilder) { Console.WriteLine("PluginBPlugin execute ConfigureAction"); PluginBDbContext pluginBDbContext = applicationBuilder .ApplicationServices .GetService <PluginBDbContext>(); PluginBDbContextInitializer.Initialize(pluginBDbContext); }
public static void Initialize(PluginBDbContext context) { context.Database.EnsureCreated(); // Look for any foos. if (context.Foos.Any()) { // DB has been seeded return; } FooEntity[] foos = new FooEntity[] { new FooEntity { Id = Guid.NewGuid(), Name = "Carson" }, new FooEntity { Id = Guid.NewGuid(), Name = "Meredith" }, new FooEntity { Id = Guid.NewGuid(), Name = "Arturo" }, new FooEntity { Id = Guid.NewGuid(), Name = "Gytis" }, new FooEntity { Id = Guid.NewGuid(), Name = "Yan" }, }; foreach (FooEntity s in foos) { context.Foos.Add(s); } context.SaveChanges(); }
public FooEFMepository(PluginBDbContext dbContext) { this._dbContext = dbContext; }