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
  • 相关阅读:
    博客园的界面设置
    ARM 汇编指令集
    winfroms更换皮肤
    面向对象的七项设计原则
    S2-01
    机票查询与订购系统
    重点语法
    第二章
    一、17.09.13
    习作
  • 原文地址:https://www.cnblogs.com/mschen/p/12524514.html
Copyright © 2011-2022 走看看