Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

What of DbConfigurationType? #1104

Answered by bgrainger
juho2-hamk asked this question in Q&A
Discussion options

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.
You must be logged in to vote

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

Comment options

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.

You must be logged in to vote
1 reply
Comment options

Thanks for your reply. Unfortunately migrating away from .NET FW is not possible. I suppose I'll have to keep using MySql.Data.

Answer selected by juho2-hamk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /