I have 2 projects in my solution, I have a project with Entity Framework Core installed:
And in the other ASP.NET Web API project I have these packages:
<?xml version="1.0" encoding="utf-8"?> <packages> <package id="Antlr" version="3.5.0.2" targetFramework="net461" /> <package id="Microsoft.ApplicationInsights" version="2.5.1" targetFramework="net461" /> <package id="Microsoft.ApplicationInsights.Agent.Intercept" version="2.4.0" targetFramework="net461" /> <package id="Microsoft.ApplicationInsights.DependencyCollector" version="2.5.1" targetFramework="net461" /> <package id="Microsoft.ApplicationInsights.PerfCounterCollector" version="2.5.1" targetFramework="net461" /> <package id="Microsoft.ApplicationInsights.Web" version="2.5.1" targetFramework="net461" /> <package id="Microsoft.ApplicationInsights.WindowsServer" version="2.5.1" targetFramework="net461" /> <package id="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" version="2.5.1" targetFramework="net461" /> <package id="Microsoft.AspNet.Mvc" version="5.2.4" targetFramework="net461" /> <package id="Microsoft.AspNet.Razor" version="3.2.4" targetFramework="net461" /> <package id="Microsoft.AspNet.TelemetryCorrelation" version="1.0.0" targetFramework="net461" /> <package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net461" /> <package id="Microsoft.AspNet.WebApi" version="5.2.4" targetFramework="net461" /> <package id="Microsoft.AspNet.WebApi.Client" version="5.2.4" targetFramework="net461" /> <package id="Microsoft.AspNet.WebApi.Core" version="5.2.4" targetFramework="net461" /> <package id="Microsoft.AspNet.WebApi.HelpPage" version="5.2.4" targetFramework="net461" /> <package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.4" targetFramework="net461" /> <package id="Microsoft.AspNet.WebPages" version="3.2.4" targetFramework="net461" /> <package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.0" targetFramework="net461" /> <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net461" /> <package id="Newtonsoft.Json" version="11.0.1" targetFramework="net461" /> <package id="System.Diagnostics.DiagnosticSource" version="4.4.1" targetFramework="net461" /> <package id="WebGrease" version="1.6.0" targetFramework="net461" /> </packages>
When I run Add-Migration
in PMC:
Your startup project 'API' doesn't reference Microsoft.EntityFrameworkCore.Design. This package is required for the Entity Framework Core Tools to work. Ensure your startup project is correct, install the package, and try again.
I installed Microsoft.EntityFrameworkCore.Design in the startup project instead of the data project that will contain all the entities and now it works, is this how the project should be setup?
Microsoft. EntityFrameworkCore. Design contains all the design-time logic for Entity Framework Core. It's the code that all of the various tools (PMC cmdlets like Add-Migration , dotnet ef & ef.exe ) call into. If you don't use Migrations or Reverse Engineering, you don't need it.
You can use EF Core in APIs and applications that require the full . NET Framework, as well as those that target only the cross-platform .
The Entity Framework Core tools help with design-time development tasks. They're primarily used to manage Migrations and to scaffold a DbContext and entity types by reverse engineering the schema of a database.
I found the solution here.
In short, edit your csproj file, and add to your PropertyGroup
section following entry:
<GenerateRuntimeConfigurationFiles>True</GenerateRuntimeConfigurationFiles>
None of the options worked for me. But the one I tried on this topic worked: EF Core 3 design time migrations broken by Microsoft.EntityFrameworkCore.Design DevelopmentDependency
I just commented out the following after importing the package to the Data project:
<ItemGroup> <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.4" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.5"> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <!--<PrivateAssets>all</PrivateAssets>--> </PackageReference>
Thank you so much Microsoft by breaking the existing projects every time when you release a new .NetCore update!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With