public DbContextFactory(IServiceScopeFactory scopeFactory) { _scope = scopeFactory.CreateScope(); _dbContext = _scope.ServiceProvider.GetRequiredService <PlanetmansDbContext>(); _dbContext.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new PlanetmansDbContext( serviceProvider.GetRequiredService < DbContextOptions <PlanetmansDbContext> >())) { context.Database.Migrate(); return; } }