zoukankan      html  css  js  c++  java
  • EF Core 多 DbContext 迁移

    public class FirstDbContext : DbContext
        {
            public FirstDbContext(DbContextOptions<FirstDbContext> options)
                : base(options)
            { }
            public DbSet<xx> xxxs{ get; set; }
            public DbSet<xx> xxxs{ get; set; }
        }
    
    public class SecondDbContext : DbContext
        {
            public SecondDbContext (DbContextOptions<FirstDbContext> options)
                : base(options)
            { }
            public DbSet<xx> xxxs{ get; set; }
            public DbSet<xx> xxxs{ get; set; }
        }
    
    
    public void ConfigureServices(IServiceCollection services)
     {
    services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            var connection = @"xxx"; 
            services.AddDbContext<FirstDbContext> 
                (options => options.UseSqlServer(connection)); 
            var secondDbconnection = @"xxx"; 
            services.AddDbContext<SecondDbContext> 
                (options => options.UseSqlServer(secondDbconnection)); 
        }
    Add-Migration InitialCreate -Context FirstDbContext -OutputDir MigrationsFirstDbContextMigrations
    Update-Database -Context FirstDbContext
  • 相关阅读:
    python 小练习 5
    python 小练习4
    python 小练习3
    python 小练习2
    遇到后缀名为whl的库的安装方法
    hdu1394Minimum Inversion Number
    Triangle
    codeforces B. Pasha and String
    F
    C
  • 原文地址:https://www.cnblogs.com/mschen/p/12524514.html
Copyright © 2011-2022 走看看