问题描述
谁能指出我犯错的地方.我正在尝试通过SQLite(Console App .NET Core 3.1)在EFCore上进行迁移.
Can anyone point me in the direction of where I have gone wrong. I am trying to get migrations to work on EFCore with SQLite (Console App .NET Core 3.1)
运行任何命令(例如enable-migrations或update-database)都会给出错误;
Running any command such as enable-migrations or update-database gives the error;
您的目标项目"XXX"未引用EntityFramework.该软件包供实体框架核心工具使用.确保您的目标项目正确,安装软件包,然后重试.
Your target project 'XXX' doesn't reference EntityFramework. This package is for the Entity Framework Core Tools to work. Ensure your target project is correct, install the package, and try again.
如果我使用EFCore,似乎需要EntityFramework有点奇怪吗?
Seems a bit weird to need the EntityFramework if I am using EFCore??
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
推荐答案
在我的情况下,我遇到了同样的异常,因为我与EntityFrameWorkCore一起安装了EntityFrameWork软件包.我在以后的版本中使用了我的库中执行SqlCommand的一些较旧的功能.
In my case I was getting this same exceptions because I had the EntityFrameWork package installed along with EntityFrameWorkCore. I was using the later for some older functions I had in my Library which executed SqlCommand.
安装两个软件包都彻底擦洗了我的项目,即使在删除EntityFramework软件包之后也是如此.Michael Browns的评论给了我一个提示,因为我最终不得不按照以下建议完全重设EntityFramework Migrations:重置实体框架
Installing both packages completely scrubbed my project even after I removed the EntityFramework package. Michael Browns comment gave me a hint as I ended up having to completely reset my EntityFramework Migrations by following this suggestion:Reset Entity Framework
这篇关于您的目标项目"XXX"未引用EntityFramework.此套餐为必填项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!