【问题标题】:Could not load assembly 'CommonBaseData'. Ensure it is referenced by the startup project 'CommonBaseType'无法加载程序集“CommonBaseData”。确保它被启动项目“CommonBaseType”引用
【发布时间】:2021-07-08 20:05:23
【问题描述】:

我想创建微服务架构解决方案,因此我为我的解决方案添加了一些服务。我的所有服务都必须在我的数据库中的模型中有一个表,因此我添加了写入此迁移以从我的数据库中添加一个表:

 Scaffold-DbContext -Connection "Server=DESKTOP-9Q51Q00\TMF;Database=DataModelSection;Trusted_Connection=True;" -Provider Microsoft.EntityFrameworkCore.SqlServer -OutputDir Model -Tables tblCommonBaseType -Context "Contexts"

我想要从我的数据库中成功获得的表:

enter image description here

但是当我创建项目 #2 并且我想使用此迁移并添加另一个表时,我收到错误并且构建失败。

 Scaffold-DbContext -Connection "Server=DESKTOP-9Q51Q00\TMF;Database=DataModelSection;Trusted_Connection=True;" -Provider Microsoft.EntityFrameworkCore.SqlServer -OutputDir Model -Tables tblCommonBaseData -Context "Contexts" 

enter image description here

【问题讨论】:

  • 打开错误窗口并检查问题所在。
  • 无法加载程序集“CommonBaseData”。确保它被启动项目“CommonBaseType”引用。

标签: c# asp.net-core entity-framework-core migration microservices


【解决方案1】:

当当前项目不是启动项目时,通常会出现此错误。

您可以右键单击该项目,然后单击“设置为启动项目”

您似乎想在两个项目之间共享同一个数据库?

您可以将实体框架代码移动到共享类库中并在其中引用它

两个项目,不需要用同一个数据库两次脚手架,可能会发生一些 冲突。

【讨论】:

    猜你喜欢
    • 2021-01-25
    • 2021-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多