您的启动项目“项目”未引用Microsoft.EntityFrameworkCore.Design

时间:2019-02-21 05:34:09

标签: entity-framework nuget-package

我正在使用EntityFrameworkCore版本2.2.2构建WPF应用程序

但是,当我想Add-Migration时会向我输出错误...

Your startup project 'project' 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.

我不知道为什么会这样,因为我可以在出现此错误之前使用它。

这是我的packages.config文件

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Costura.Fody" version="3.3.2" targetFramework="net461" />
  <package id="Fody" version="4.0.2" targetFramework="net461" developmentDependency="true" />
  <package id="Microsoft.CSharp" version="4.5.0" targetFramework="net461" />
  <package id="Microsoft.Data.Sqlite.Core" version="2.2.2" targetFramework="net461" />
  <package id="Microsoft.DotNet.PlatformAbstractions" version="2.1.0" targetFramework="net461" />
  <package id="Microsoft.EntityFrameworkCore" version="2.2.2" targetFramework="net461" />
  <package id="Microsoft.EntityFrameworkCore.Abstractions" version="2.2.2" targetFramework="net461" />
  <package id="Microsoft.EntityFrameworkCore.Analyzers" version="2.2.2" targetFramework="net461" />
  <package id="Microsoft.EntityFrameworkCore.Design" version="2.2.2" targetFramework="net461" />
  <package id="Microsoft.EntityFrameworkCore.Relational" version="2.2.2" targetFramework="net461" />
  <package id="Microsoft.EntityFrameworkCore.Sqlite" version="2.2.2" targetFramework="net461" />
  <package id="Microsoft.EntityFrameworkCore.Sqlite.Core" version="2.2.2" targetFramework="net461" />
  <package id="Microsoft.EntityFrameworkCore.Tools" version="2.2.2" targetFramework="net461" developmentDependency="true" />
  <package id="Microsoft.Extensions.Caching.Abstractions" version="2.2.0" targetFramework="net461" />
  <package id="Microsoft.Extensions.Caching.Memory" version="2.2.0" targetFramework="net461" />
  <package id="Microsoft.Extensions.Configuration" version="2.2.0" targetFramework="net461" />
  <package id="Microsoft.Extensions.Configuration.Abstractions" version="2.2.0" targetFramework="net461" />
  <package id="Microsoft.Extensions.Configuration.Binder" version="2.2.0" targetFramework="net461" />
  <package id="Microsoft.Extensions.DependencyInjection" version="2.2.0" targetFramework="net461" />
  <package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="2.2.0" targetFramework="net461" />
  <package id="Microsoft.Extensions.DependencyModel" version="2.1.0" targetFramework="net461" />
  <package id="Microsoft.Extensions.Logging" version="2.2.0" targetFramework="net461" />
  <package id="Microsoft.Extensions.Logging.Abstractions" version="2.2.0" targetFramework="net461" />
  <package id="Microsoft.Extensions.Options" version="2.2.0" targetFramework="net461" />
  <package id="Microsoft.Extensions.Primitives" version="2.2.0" targetFramework="net461" />
  <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net461" />
  <package id="Remotion.Linq" version="2.2.0" targetFramework="net461" />
  <package id="SQLitePCLRaw.bundle_green" version="1.1.12" targetFramework="net461" />
  <package id="SQLitePCLRaw.core" version="1.1.12" targetFramework="net461" />
  <package id="SQLitePCLRaw.lib.e_sqlite3.linux" version="1.1.12" targetFramework="net461" />
  <package id="SQLitePCLRaw.lib.e_sqlite3.osx" version="1.1.12" targetFramework="net461" />
  <package id="SQLitePCLRaw.lib.e_sqlite3.v110_xp" version="1.1.12" targetFramework="net461" />
  <package id="SQLitePCLRaw.provider.e_sqlite3.net45" version="1.1.12" targetFramework="net461" />
  <package id="System.Buffers" version="4.4.0" targetFramework="net461" />
  <package id="System.Collections.Immutable" version="1.5.0" targetFramework="net461" />
  <package id="System.ComponentModel.Annotations" version="4.5.0" targetFramework="net461" />
  <package id="System.Diagnostics.DiagnosticSource" version="4.5.0" targetFramework="net461" />
  <package id="System.Interactive.Async" version="3.2.0" targetFramework="net461" />
  <package id="System.Memory" version="4.5.1" targetFramework="net461" />
  <package id="System.Numerics.Vectors" version="4.4.0" targetFramework="net461" />
  <package id="System.Runtime.CompilerServices.Unsafe" version="4.5.1" targetFramework="net461" />
  <package id="System.Runtime.InteropServices.RuntimeInformation" version="4.0.0" targetFramework="net461" />
</packages>

该软件包已经安装。

NuGet Package Manager

非常感谢您提供帮助。

3 个答案:

答案 0 :(得分:1)

我确实使用此命令安装了它,并且有效!

我正在使用.net核心版本3.1.1

dotnet add package Microsoft.EntityFrameworkCore.Design --version 3.1.1

答案 1 :(得分:0)

Add-Migration可能会引起困惑,因为您正在使用Costura嵌入程序集。尝试删除costura以查看是否可以解决问题。

答案 2 :(得分:0)

使用PMC再次安装它,然后它将找到引用:

PM> dotnet add package Microsoft.EntityFrameworkCore.Design