无法在.NET Standard 2项目中使用实体框架 [英] Cannot use Entity Framework in .NET standard 2 project

查看:478
本文介绍了无法在.NET Standard 2项目中使用实体框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Entity Framework或.NET Standard项目中的类似内容?

.NET Standard 2中似乎不支持EF,这确实很烦人!

所以我尝试使用Microsoft.EntityFrameworkCore.SqlServer和icrosoft.EntityFrameworkCore.SqlServer.Design

我可以安装这些软件包,之后就无法添加模型

我收到错误

---------------------------
Microsoft Visual Studio
---------------------------
The project's target framework does not contain Entity Framework runtime assemblies. Please review the target framework information in the project's property page.
---------------------------
OK   
---------------------------

我该如何解决?

我正在认真地考虑从我的所有项目中摆脱.NET Standard的问题,但这有点太过疯狂了!

保罗

解决方案

看来,实际的问题是如何像使用EF 6一样,如何使用EF Core创建模型和对数据库进行反向工程"?

该工具与NuGet软件包分开. Visual Studio 2017不包括用于EF Core的建模或逆向工程工具.可以通过 EF Core Power Tools 开源插件获得.您可以在此处

找到代码和文档.

How can I use Entity Framework, or something similar within a .NET Standard project?

It appears as though EF is not supported in .NET Standard 2 which is really annoying!

So I have tried using Microsoft.EntityFrameworkCore.SqlServer and icrosoft.EntityFrameworkCore.SqlServer.Design

Whist I can install these packages, I cannot then add a model

I get the error

---------------------------
Microsoft Visual Studio
---------------------------
The project's target framework does not contain Entity Framework runtime assemblies. Please review the target framework information in the project's property page.
---------------------------
OK   
---------------------------

How can I get around this?

I am seriously thinking to get rid of .NET Standard out of all my projects but that is a bit drastic!

Paul

解决方案

It looks like the actual question is "How can I create models and reverse engineer a database using EF Core like I could with EF 6" ?

The tooling is separate from the NuGet package. Visual Studio 2017 doesn't include modelling or reverse engineer tools for EF Core. Those are available through EF Core Power Tools an open source addon. You can find the code and documentation here

这篇关于无法在.NET Standard 2项目中使用实体框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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