protected override void Seed(Com.Qualcomm.Qswat.Data.Context.EfContext context) { // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. var seed = new DataSeeds(context); seed.SeedAll(); }
static void Main() { Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ConfigureServices(); /// seed data var context = ServiceProvider.GetRequiredService <ElectronicsStoreContext> (); var unitOfWork = ServiceProvider.GetRequiredService <IUnitOfWork> (); DataSeeds.Initialize(context, unitOfWork); context.SaveChanges(); ///run forms var mainForm = ServiceProvider.GetRequiredService <MainForm> (); Application.Run(mainForm); }
public static void Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; var context = services.GetRequiredService <ToDoListContext>(); try { DataSeeds.Initialize(context); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError("An error occured seeding database.", ex); } } host.Run(); }
public static void Main() { Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ///register services ConfigureServices(); /// seed data var context = ServiceProvider.GetRequiredService <ManageToursContext>(); DataSeeds.Initalize(context); context.SaveChanges(); ///run forms var mainForm = ServiceProvider.GetRequiredService <MainForm>(); Application.Run(mainForm); }