简体   繁体   中英

Can I use Pomelo.EntityFrameworkCore.MySql with .NET Framework 4.x?

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

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM