System.IO.FileNotFoundException when creating EF migrations on .net core

.net-core c# entity-framework-core


I have a .NET Core 2.2 project and am trying to set up EF migrations.

When running:

dotnet ef migrations add init --verbose

I get the following errors:

Finding design-time services for provider 'Microsoft.EntityFrameworkCore.SqlServer'... Using design-time services from provider 'Microsoft.EntityFrameworkCore.SqlServer'. Finding design-time services referenced by assembly 'myproject-api'. No referenced design-time services were found. Finding IDesignTimeServices implementations in assembly 'myproject-api'... No design-time services were found. System.IO.FileNotFoundException: Could not load file or assembly 'myproject, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

This is my csproj file:

<Project Sdk="Microsoft.NET.Sdk.Web">


    <Folder Include="wwwroot\" />

    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.4" />
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.4" />


Edit, here is my Program.cs

public class Program
    public static void Main(string[] args)

    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>

10/29/2019 10:25:22 PM

Popular Answer


Add context name to options constructor.

 public MyDbContext(DbContextOptions<**MyDbContext**> options)
      : base(options)

Migration command.

Add-Migration MyMig -Context MyDbContext

and install the "Microsoft.EntityFrameworkCore.SqlServer" package on the "myproject-api" layer if it is not installed.

10/25/2019 11:45:16 AM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow