-
Notifications
You must be signed in to change notification settings - Fork 345
What of DbConfigurationType? #1104
-
I am attempting to migrate multiple projects from MySql.Data and MySql.EntityFramework to MySqlConnector. I am however having trouble understanding how to replace MySql.EntityFramework.
My projects are actually extensions to a proprietary application. As such, app.config/web.config would be ignored because the extension project is not the main project being loaded at startup.
Below is an example of how I have worked around this issue in MySql.Data.EntityFramework. How do I make this work with MySqlConnector?
The important part is this: [DbConfigurationType(typeof(MySqlEFConfiguration))]
using System.Data.Common;
using System.Data.Entity;
using MySql.Data.EntityFramework;
namespace My.Extension
{
[DbConfigurationType(typeof(MySqlEFConfiguration))]
internal class DataModel : DbContext
{
public DataModel(DbConnection dbConnection)
: base(dbConnection, true)
{
}
// class properties
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
// modelBuilder.Entity stuff
}
}
}
EDIT: Oh I see, apparently I also need Pomelo.EntityFrameworkCore.MySql. Haven't checked it out yet, so I am not sure if it is quite as drop-in replacement to MySql.Data.EntityFramework as MySqlConnector is to MySql.Data.
I am however starting to doubt if changing dependencies is worthwhile in my case.,
- Stuck with .NET Framework
- Having to support MariaDB version as old as 10.1.38.
- Async isn't needed in my use-case.
Beta Was this translation helpful? Give feedback.
All reactions
There is no Entity Framework driver for MySQL that uses MySqlConnector. If you're using EF, you need to stick with MySql.Data.EntityFramework (and MySql.Data).
If you're using Entity Framework Core, then Pomelo.EntityFrameworkCore.MySql is a replacement for MySql.Data.EntityFrameworkCore or MySql.EntityFrameworkCore.
You'll have to evaluate the migration effort, but it may not be worth switching from EF to EF Core just to use MySqlConnector, particularly if that also requires a switch from .NET Framework to .NET 6.0.
Replies: 1 comment 1 reply
-
There is no Entity Framework driver for MySQL that uses MySqlConnector. If you're using EF, you need to stick with MySql.Data.EntityFramework (and MySql.Data).
If you're using Entity Framework Core, then Pomelo.EntityFrameworkCore.MySql is a replacement for MySql.Data.EntityFrameworkCore or MySql.EntityFrameworkCore.
You'll have to evaluate the migration effort, but it may not be worth switching from EF to EF Core just to use MySqlConnector, particularly if that also requires a switch from .NET Framework to .NET 6.0.
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks for your reply. Unfortunately migrating away from .NET FW is not possible. I suppose I'll have to keep using MySql.Data.
Beta Was this translation helpful? Give feedback.