'Could not load assembly 'CommonBaseData'. Ensure it is referenced by the startup project 'CommonBaseType'
I want create micro service architecture solution so I add some services for my solution. All my services must have one table in my database in there models so I add write this migrations for add one table from my database:
Scaffold-DbContext -Connection "Server=DESKTOP-9Q51Q00\TMF;Database=DataModelSection;Trusted_Connection=True;" -Provider Microsoft.EntityFrameworkCore.SqlServer -OutputDir Model -Tables tblCommonBaseType -Context "Contexts"
The table which I want from my database successfully:
but when I create project #2 and I want to use this migration, and add one more table, I get an error and the build fails.
Scaffold-DbContext -Connection "Server=DESKTOP-9Q51Q00\TMF;Database=DataModelSection;Trusted_Connection=True;" -Provider Microsoft.EntityFrameworkCore.SqlServer -OutputDir Model -Tables tblCommonBaseData -Context "Contexts"
Solution 1:[1]
This error often caused when the current project is not the startup project.
You can right click the project and click 'set as a startup project'
Looks like you want to share the same database between two projects?
You can move the Entity Framework code into a shared class library and reference it in
two projects, no need to scaffold twice with the same database, it may occur some conflicts.
Solution 2:[2]
You can try right clicking on the solution and clicking on "Set as Startup Project"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Jerry Cai |
Solution 2 | NorbertoMarcelo |