Tag: database migration

在Asp.Net Core中使用两个上下文进行数据库迁移(Docker上的SQL Server)

我的应用程序中有两个上下文。 一个在WebApi Project -> ApiContext (inherited from IdentityDbContext) ,另一个在Infrastructure -> Context 。 我使用Docker Engine( microsoft/mssql-server-linux )的Linux上的Microsoft SQL Server的官方图像。 我写了一个DbFactory 。 下面你可以find我的代码。 ApiContext:内部类ApiContext:IdentityDbContext {公共ApiContext(DbContextOptions选项):基地(选项){Database.EnsureDeleted(); } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); } } 上下文 内部类上下文:DbContext {公共上下文(DbContextOptions选项):基地(选项){Database.EnsureCreated(); } public DbSet<Reservation> Reservations { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Entity<Table>().ToTable("Table"); } } 在我的基础设施项目中,我曾经说过DbFactory […]