您的启动项目没有引用Microsoft.EntityFrameworkCore.Design [英] Your startup project doesn't reference Microsoft.EntityFrameworkCore.Design

查看:319
本文介绍了您的启动项目没有引用Microsoft.EntityFrameworkCore.Design的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的解决方案中有2个项目,我有一个安装了Entity Framework Core的项目:

I have 2 projects in my solution, I have a project with Entity Framework Core installed:

在另一个ASP.NET Web API项目中,我有以下软件包:

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>

当我在PMC中运行 Add-migration 时:

When I run Add-Migration in PMC:


您的启动项目 API未引用
Microsoft.EntityFrameworkCore.Design。该软件包是
实体框架核心工具运行所必需的。确保您的启动项目正确
,安装软件包,然后重试。

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.

我在以下位置安装了Microsoft.EntityFrameworkCore.Design

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?

推荐答案

是启动项目,而不是将包含所有实体的数据项目,现在它可以工作了。

我在这里找到了解决方案: http:// obscureproblemsandgotchas .com / development / c / dotnet-core-ef-migration-not-working /

I found the solution here: http://obscureproblemsandgotchas.com/development/c/dotnet-core-ef-migration-not-working/

简而言之,编辑您的csproj文件,并将其添加到 PropertyGroup 部分,如下所示:

In short, edit your csproj file, and add to your PropertyGroup section following entry:

<GenerateRuntimeConfigurationFiles>True</GenerateRuntimeConfigurationFiles>

这篇关于您的启动项目没有引用Microsoft.EntityFrameworkCore.Design的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆