我可以在 .NET Framework 4.x 中使用 Pomelo.EntityFrameworkCore.MySql 吗? [英] Can I use Pomelo.EntityFrameworkCore.MySql with .NET Framework 4.x?

查看:61
本文介绍了我可以在 .NET Framework 4.x 中使用 Pomelo.EntityFrameworkCore.MySql 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的堆栈从 Oracle 的 Connector/NETMySql.Data.Entity 更改为 MySqlConnectorPomelo EF Provider一>.

I want to change my stack from Oracle's Connector/NET and MySql.Data.Entity to MySqlConnector and Pomelo EF Provider.

Pomelo.EntityFrameworkCore.MySql 适用于 .NET Core.但是我可以将它用于好的旧 .NET 项目吗?我在 Pomelo 的 GitHub 页面上找不到帮助,但是 如何配置XML 配置中的 Pomelo.EntityFrameworkCore.MySql?Pomelo.EntityFrameworkCore.MySQL DBContext 抛出Unqualified data type char"例外建议如此.

Pomelo.EntityFrameworkCore.MySql is meant for .NET Core all right. But can I use it for good old .NET Projects? I do not find help at Pomelo's GitHub pages, but How to configure Pomelo.EntityFrameworkCore.MySql in XML configuration? and Pomelo.EntityFrameworkCore.MySQL DBContext throwing "Unqualified data type char" exception suggest so.

我宁愿事先知道,而不是尝试了几天,最后还是失败了.

I'd rather know beforehand and not try for days and finally fail.

推荐答案

Pomelo/MySqlConnector 解决方案确实可以与 .NET Framework 一起使用.正如 P. Kanavos 所说,困难的部分是必须切换到 EF Core.这也适用于 .NET Framework,但与 EF 6.x 有很大不同.如果您使用 EF 很简单,那么更改应该不会太困难.但是,在我的应用程序中,设计严重依赖于 EF Core 中不存在的 EF6 功能.(具体来说,链接实体的链式包含,包括通过集合.)此外,我们正在编写表示一个类中的查询(带有包含)的表达式,并将它们通过另一个类传递到存储库中.该流程不适用于 EF Core 的流畅查询组合.

The Pomelo/MySqlConnector solution can indeed be used with .NET Framework. As P. Kanavos says, the hard part is having to switch to EF Core. That also works with .NET Framework, but is significantly different from EF 6.x. If your use of EF is straightforward, the change should not be overly difficult. In my application, though, the design was heavily dependent on EF6 functionality that is not present in EF Core. (Specifically, chained inclusions of linked entities, including through collections.) Also, we were composing expressions that represented the queries (with inclusions) in one class, and passing those through another class into the repository. That flow doesn't work nicely with EF Core's fluent composition of queries.

最后,我们最终将数据库移至 MS SQL Server.但是对于Entity Framework 的更常规的使用,切换到EF Core + Pomelo + MySqlConnector 是可行的.

In the end, we wound up moving our database to MS SQL Server instead. But for a more conventional use of Entity Framework, it is feasible to switch to EF Core + Pomelo + MySqlConnector.

这篇关于我可以在 .NET Framework 4.x 中使用 Pomelo.EntityFrameworkCore.MySql 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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