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
  • 相关阅读:
    P4995 跳跳!
    P4306 [JSOI2010]连通数
    P1339 [USACO09OCT]热浪Heat Wave
    P2002 消息扩散
    P3388 【模板】割点(割顶)
    P1656 炸铁路
    P2863 [USACO06JAN]牛的舞会The Cow Prom
    P1516 青蛙的约会
    3.从尾到头打印链表
    2.替换空格
  • 原文地址:https://www.cnblogs.com/mschen/p/12524514.html
Copyright © 2011-2022 走看看