Can´t generate migrations using .NET Core Tools MSBuild from the CLI
See original GitHub issueI can´t generate a new migration from a class library project even when setting a valid ASP.NET Core Web API application as a startup project.
Error message: Could not invoke this command on the startup project '{project-dir}'. This version of the Entity Framework Core .NET Command Line Tools does not support commands on class library projects in ASP.NET Core and .NET Core applications. See http://go.microsoft.com/fwlink/?LinkId=798221 for details and workarounds.
Steps to reproduce
- Execute the following command on the library project folder :
dotnet ef -s ../{asp.net core app dir} migrations add FirstMigration
Further technical details
EF Core version: 1.1.0 EF Core Tools version: 1.0.0-msbuild2-final Database Provider: Microsoft.EntityFrameworkCore.SqlServer Operating system: Mac OS 10.12.2 IDE: Visual Studio Code
Issue Analytics
- State:
- Created 7 years ago
- Comments:16 (7 by maintainers)
Top Results From Across the Web
Cannot add migration in .NET Core using CLI
I have experience to use EF migrations in .NET MVC but after switching to .NET Core and CLI, now I cannot apply migrations...
Read more >dotnet migrate command - .NET CLI
The dotnet migrate command migrates a project and all of its dependencies.
Read more >EF Core Migrations using CLI
Open command prompt and navigate to your project's root folder and enter dotnet ef --help to list EF Core commands, as shown below....
Read more >Troubleshooting the dotnet ef command for EF Core ...
NET core ), it's easy to run into a problem when attempting to use EF Core migrations at the command line. The most...
Read more >Command Line Interface commands
The commands available for managing the database, DbContext, and migrations from the command line.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@bricelam - Hi Brice, can you give us an example please?
Iv’e just hit this in a dotnet core web app using npgsql, and I’m not exactly clear on how to proceed.
Actual Exception is:
Startup project 'gis.database.csproj' targets framework '.NETStandard'. This framework is not intended for execution and may fail to resolve runtime dependencie s. If so, specify a different project using the --startup-project option and try again. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Design, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified. File name: 'Microsoft.EntityFrameworkCore.Design, Culture=neutral, PublicKeyToken=null' at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMar k& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.Assembly.Load(AssemblyName assemblyRef) at Microsoft.EntityFrameworkCore.Tools.ReflectionOperationExecutor..ctor(String assembly, String startupAssembly, String projectDir, String contentRootPath, String dataDirectory, String rootNamespace, String environment) at Microsoft.EntityFrameworkCore.Tools.Commands.ProjectCommandBase.CreateExecutor() at Microsoft.EntityFrameworkCore.Tools.Commands.MigrationsAddCommand.Execute() at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args) at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args) Could not load file or assembly 'Microsoft.EntityFrameworkCore.Design, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
My EF stuff is in a seperate .NETStandard class library, in a folder called “gis.database”, while the actual web app running standalone is in ‘…/gis.web/’
How can I make ef migrations run in this case, based on your comments above?