I have experience to use EF migrations in .NET MVC but after switching to .NET Core and CLI, now I cannot apply migrations using CLI. Here are the commands that I use, but I am not sure in which project I should open CLI.
Assume that I open CLI on the solution directory and there are 2 projects; Domain project contains Entities, and Infrastructure project contains Migrations folder:
add-migration
dotnet ef migrations add AddDateOfBirthField --project src\Domain
--context ApplicationDbContext --output-dir src\Infrastructure\Migrations
Throws the following error:
Startup project 'Domain.csproj' targets framework '.NETStandard'. There is no runtime associated with this framework, and projects targeting it cannot be executed directly. To use the Entity Framework Core .NET Command-line Tools with this project, add an executable project targeting .NET Core or .NET Framework that references this project, and set it as the startup project using --startup-project; or, update this project to cross-target .NET Core or .NET Framework. For more information on using the Entity Framework Tools with .NET Standard projects, see https://go.microsoft.com/fwlink/?linkid=2034781
So, should I execute the command from another directory of CLI or use an extra flag e.g. --startup-project
?
Entity Framework Core
? – zertuc--project src\Domain
type is not .Net Core or .Net framework. That's why you are getting this error. – Berkay