public static void InizializeReasonsForExpenderAndIncome(IApplicationBuilder app) { using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope()) { var context = serviceScope.ServiceProvider.GetService <ApplicationDbContext>(); context.Database.EnsureCreated(); if (context.ResonsForExpenderAndIncome.Any()) { return; } List <ResonsForExpenderAndIncome> listOfResons = DeveloperUsersAndData.GetResons(context).ToList <ResonsForExpenderAndIncome>(); context.ResonsForExpenderAndIncome.AddRange(listOfResons); context.SaveChanges(); } }
public static void InizializeUsersInfo(IApplicationBuilder app) { using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope()) { var context = serviceScope.ServiceProvider.GetService <ApplicationDbContext>(); context.Database.EnsureCreated(); if (context.UsersIndo.Any()) { return; } List <UserInfo> informationList = DeveloperUsersAndData.GetUsersInfo(context).ToList <UserInfo>(); context.UsersIndo.AddRange(informationList); context.SaveChanges(); } }