Can't find anything relevant about Entity Framework/MySQL on Google so I'm hoping someone knows about it.
-
8frankly speaking, mysql support for LINQ is crap! I am banging my head on minor issues for last one week :| ... – effkay Dec 25 '09 at 07:04
-
1did u use dblinq http://code.google.com/p/dblinq2007/? – Sharique Jul 14 '10 at 07:34
10 Answers
It's been released - Get the MySQL connector for .Net v6.5 - this has support for [Entity Framework]
I was waiting for this the whole time, although the support is basic, works for most basic scenarios of db interaction. It also has basic Visual Studio integration.
UPDATE http://dev.mysql.com/downloads/connector/net/ Starting with version 6.7, Connector/Net will no longer include the MySQL for Visual Studio integration. That functionality is now available in a separate product called MySQL for Visual Studio available using the MySQL Installer for Windows (see http://dev.mysql.com/tech-resources/articles/mysql-installer-for-windows.html).
-
-
4I thought I'd mention that the latest version is available here (current 6.2.2): http://www.mysql.com/downloads/connector/net – Brett Ryan Mar 10 '10 at 14:34
-
3Does this support EF4 and VS2010? I installed the connector and tried to add a new connection in VS2010 but MySQL does not show up in the list of providers – Abhijeet Patel May 13 '10 at 07:07
-
1
-
1It should if you have the latest connector. I just moved my product to .NET4 specifically because of MySQL Entity support. The tools and everything work okay, but the big issue is the underlying support it provides for actual querying. There's quite a few problems with lamba expressions that you don't run into with MSSQL – David Anderson Aug 18 '11 at 03:30
-
It took me quite a while to find this so I wanted to share in case anyone else gets an "Out of sync with server" error running the latest version(6.4.3), it is a known bug fixed in version 6.4.4+. http://bugs.mysql.com/bug.php?id=61806 – Johnie Karr Sep 14 '11 at 01:48
-
If you experience an issue with the DatabaseInitializer take a look at the following link http://brice-lambson.blogspot.com/2012/05/using-entity-framework-code-first-with.html. – sky-dev Sep 10 '12 at 19:24
-
-
1Ofcourse, there are new versions coming out. Now supporting EF5, version 6.7.4: http://dev.mysql.com/downloads/connector/net/#downloads Also, Since this version, the VS plugin with MySQL server and other tools included is bundled in one package: http://dev.mysql.com/tech-resources/articles/mysql-installer-for-windows.html – Nullius Jul 19 '13 at 13:32
-
Is using MYSQL with EF got any better or there are still issues?if SQL server is preferable can anyone pinpoint exactly why SQL server is preferable just because its the same vendor Microsoft? – user3508811 Feb 18 '17 at 02:45
Check out my post on this subject.

- 7,783
- 26
- 40

- 1,282
- 11
- 13
-
I fixed the encoding of that link - users can now click right through rather than have to copy/paste or select/goto – kͩeͣmͮpͥ ͩ Apr 18 '11 at 13:58
-
7
-
2You can get to the articles with this link: http://pattersonc.com/blog/2009/04/ – Andy White Jan 17 '12 at 19:54
-
Is using MYSQL with EF got any better or there are still issues?if SQL server is preferable can anyone pinpoint exactly why SQL server is preferable just because its the same vendor Microsoft? – user3508811 Feb 18 '17 at 02:45
MySQL is hosting a webinar about EF in a few days... Look here: http://www.mysql.com/news-and-events/web-seminars/display-204.html
edit: That webinar is now at http://www.mysql.com/news-and-events/on-demand-webinars/display-od-204.html

- 538,548
- 86
- 673
- 828

- 595
- 6
- 16
This isn't about MS and what they want. They have created an *open system for others to plug-in 'providers' - postgres and sqlite have it - mysql is just laggin... but, good news for those interested, i too was looking for this and found that the MySql Connector/Net 6.0 will have it... you can check it out here:
http://www.upfromthesky.com/blog/post/2009/03/24/MySql-Supports-the-Entity-Framework.aspx
-
1I wonder what "initial" means when they said "Initial Entity Framework support". – vintana Mar 26 '09 at 13:36
You would need a mapping provider for MySQL. That is an extra thing the Entity Framework needs to make the magic happen. This blog talks about other mapping providers besides the one Microsoft is supplying. I haven't found any mentionings of MySQL.

- 42,837
- 6
- 126
- 143
Vintana,
Od course there's something ready now. http://www.devart.com/products.html - it's commercial although (you have a 30days trial IIRC). They make a living writing providers, so I guess it should be fast and stable. I know really big companies using their Oracle provider instead of Orace and MS ones.

- 1,646
- 1
- 17
- 31
-
Thank you for your response. @Vintana, you can find more information about dotConnect for MySQL and its advantages here http://www.devart.com/dotconnect/mysql/. To improve your work with Entity Framework entities we provide an advanced tool for visual model creation - Entity Developer http://www.devart.com/entitydeveloper/. – Devart Dec 07 '10 at 16:01
Be careful using connector .net, Connector 6.6.5 have a bug, it is not working for inserting tinyint values as identity, for example:
create table person(
Id tinyint unsigned primary key auto_increment,
Name varchar(30)
);
if you try to insert an object like this:
Person p;
p = new Person();
p.Name = 'Oware'
context.Person.Add(p);
context.SaveChanges();
You will get a Null Reference Exception:
Referencia a objeto no establecida como instancia de un objeto.:
en MySql.Data.Entity.ListFragment.WriteSql(StringBuilder sql)
en MySql.Data.Entity.SelectStatement.WriteSql(StringBuilder sql)
en MySql.Data.Entity.InsertStatement.WriteSql(StringBuilder sql)
en MySql.Data.Entity.SqlFragment.ToString()
en MySql.Data.Entity.InsertGenerator.GenerateSQL(DbCommandTree tree)
en MySql.Data.MySqlClient.MySqlProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
en System.Data.Common.DbProviderServices.CreateCommandDefinition(DbCommandTree commandTree)
en System.Data.Common.DbProviderServices.CreateCommand(DbCommandTree commandTree)
en System.Data.Mapping.Update.Internal.UpdateTranslator.CreateCommand(DbModificationCommandTree commandTree)
en System.Data.Mapping.Update.Internal.DynamicUpdateCommand.CreateCommand(UpdateTranslator translator, Dictionary`2 identifierValues)
en System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator translator, EntityConnection connection, Dictionary`2 identifierValues, List`1 generatedValues)
en System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
en System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache)
en System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
en System.Data.Entity.Internal.InternalContext.SaveChanges()
en System.Data.Entity.Internal.LazyInternalContext.SaveChanges()
en System.Data.Entity.DbContext.SaveChanges()
Until now I haven't found a solution, I had to change my tinyint identity to unsigned int identity, this solved the problem but this is not the right solution.
If you use an older version of Connector.net (I used 6.4.4) you won't have this problem.
If someone knows about the solution, please contact me.
Cheers!
Oware

- 626
- 9
- 19
-
The error is thrown because p is null. You have to create a new empty instance of the object first. I.e. Person p = new Person(); not Person p; So: `Person p = new Person(){Name = "Oware"}; context.Person.Add(p); context.SaveChanges();` – Dave Oct 10 '13 at 14:55
-
sorry I forgot to add the new line, even if I add the new line, the error stills appearing – oware Oct 11 '13 at 15:22
-
The bug is fixed in version 6.8.2. http://bugs.mysql.com/bug.php?id=70888 Connector/Net 6.8.3 is released. http://dev.mysql.com/downloads/connector/net/ – Der_Meister Jan 10 '14 at 13:20
You might also look at https://www.devart.com/dotconnect/mysql/
DevArt's connector supports EF and MySQL.

- 2,563
- 20
- 37
If you interested in running Entity Framework with MySql on mono/linux/macos, this might be helpful https://iyalovoi.wordpress.com/2015/04/06/entity-framework-with-mysql-on-mac-os/

- 1,715
- 1
- 17
- 22
-
Is using MYSQL with EF got any better or there are still issues?if SQL server is preferable can anyone pinpoint exactly why SQL server is preferable just because its the same vendor Microsoft? – user3508811 Feb 18 '17 at 02:45
-
I am not sure how it is right now, but we had pretty bad experience due to lack of features and it being overall inconsistent. MS MSQL is definitely preferable, because Microsoft puts it's own stack first. – Igor Yalovoy Feb 18 '17 at 08:51
I didn't see the link here, but there's a beta .NET Connector for MySql. Click "Development Releases" to download 6.3.2 beta, which has EF4/VS2010 integration:
http://dev.mysql.com/downloads/connector/net/5.0.html#downloads