コード例 #1
0
            public DbContextFactory(IServiceScopeFactory scopeFactory)
            {
                _scope     = scopeFactory.CreateScope();
                _dbContext = _scope.ServiceProvider.GetRequiredService <PlanetmansDbContext>();

                _dbContext.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
            }
コード例 #2
0
 public static void Initialize(IServiceProvider serviceProvider)
 {
     using (var context = new PlanetmansDbContext(
                serviceProvider.GetRequiredService <
                    DbContextOptions <PlanetmansDbContext> >()))
     {
         context.Database.Migrate();
         return;
     }
 }