private static void Migrate(IApplicationBuilder app) { using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope()) { using (NsrCommonDbContext context = serviceScope.ServiceProvider.GetService <NsrCommonDbContext>()) { context.Database.Migrate(); } } }
public static void UseNsrCommon(IApplicationBuilder app) { using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope()) { using (NsrCommonDbContext context = serviceScope.ServiceProvider.GetService <NsrCommonDbContext>()) { context.Database.Migrate(); } } ServiceLocator.Instance = app.ApplicationServices; Migrate(app); }
public CommonBaseRepository(NsrCommonDbContext context) { Context = context; }