设为首页 - 加入收藏 ASP站长网(Aspzz.Cn)- 科技、建站、经验、云计算、5G、大数据,站长网!
热搜: 创业者 手机 数据
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

实体框架 – 具有多个数据库/ DbContext的EF代码优先迁移

发布时间:2020-12-31 07:11 所属栏目:116 来源:网络整理
导读:我有两个数据库,每个数据库都有自己的dbcontext.我已经设置了两个迁移配置.我可以为第一个db ust罚款添加迁移(Add-Migration DB1_InitialCreate -ConfigurationTypeName DB1Configuration).当我尝试使用第二个db创建初始迁移时:Add-Migration DB2_InitialCre

我有两个数据库,每个数据库都有自己的dbcontext.我已经设置了两个迁移配置.我可以为第一个db ust罚款添加迁移(Add-Migration DB1_InitialCreate -ConfigurationTypeName DB1Configuration).当我尝试使用第二个db创建初始迁移时:Add-Migration DB2_InitialCreate -ConfigurationTypeName DB2Configuration,我收到以下错误:

Unable to generate an explicit migration because the following explicit migrations are pending: [201205082215265_DB1_InitialCreate]. Apply the pending explicit migrations before attempting to generate a new explicit migration.

所以我按照它说的做,并用以下内容更新数据库:

Update-Database -ConfigurationTypeName DB1Configuration

然后我尝试再次为第二个数据库添加迁移,但我一直收到相同的错误.

有关如何使迁移适用于两个数据库/上下文的任何想法?

解决方法

我已经能够回答我自己的问题了.我的两个配置类存在于同一个命名空间中.我把它们分开后,一切都运转了.

(编辑:ASP站长网)

    网友评论
    推荐文章
      热点阅读