We're in the final stages of porting a huge solution over to .Net Core (from 4.7.2), but we're not yet ready to migration to Entity Framework Core, as we make use of table-per-type hierarchies, etc. We use EF code-first. So, the project containing our DbContext and EF migrations is now running .netstandard2.1 and references EF 6.4 (which, as of v6.3 apparently supports .net core). I understand that the EF tooling changed from v6.2 -> v6.4, so our traditional way of creating an EF migration now results in the following error in the Package Manager Console:
add-migration TEST -project Data
Project 'Data' targets framework '.NETStandard'. The Entity Framework Package Manager Console Tools don't support this framework.
After some investigation, I came across this, which suggests that you need to use a .Net Core assembly as a dummy start-up project. After creating a .netcore 3.1 console app project (called Data_Startup, which references the Data project) and modifying my command slightly, I now get the following error:
dotnet ef migrations add TEST --project Data --startup-project Data_Startup -c CustomContext
No DbContext named 'CustomContext' was found.
This seems like it's at least attempting the migration, but I'm now stuck. I've tried fully qualifying the DbContext with the namespace and adding the DBContext class as a "linked file" to the new dummy project, but I'm faced with the same error.
I've also attempted to use the EF 6.4 tool: dotnet C:\Users\xxxx.nuget\packages\entityframework\6.4.0\tools\netcoreapp3.0\any\ef6.dll" migrations add TEST --assembly Data
Your target project 'Data' doesn't reference EntityFramework. This package is required for the Entity Framework Core Tools to work. Ensure your target project is correct, install the package, and try again.
...despite it definitely being installed in the Data project!
What am I doing wrong? Which tool do I actually need to use? Is this project configuration even possible?