Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

EntityFramework(Code First) and MySql (no replies)

$
0
0
I'm experimenting with EntityFramework (version 4.3.1) and CodeFirst Dev in my project. After I've defined my models and extended the DBContext as the sample on msdn, I found that the code run correctly on SQLServer, but not on MySql (version 5.1.61,connector/net version 6.4.4). The exception was like this:


Exception: MySql.Data.MySqlClient.MySqlException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
'NOT NULL,
`ProductVersion` mediumtext NOT NULL);
ALTER TABLE `HistoryRow` ' at line 6

Then I tried capturing the SQL scripts which the EntityFramework auto-generated, some statements in the scripts brought to my attention:

CREATE TABLE `__MigrationHistory`(
`MigrationId` mediumtext NOT NULL,
`CreatedOn` datetime NOT NULL,
`Model` varbinary NOT NULL,
`ProductVersion` mediumtext NOT NULL);

I copied it in the environment of MySql command line client, and got the same error message. By checking this statement block, I found the keyword "varbinary" was not supported in MySql. It could run correctly if I changed "varbinary" to "varbinary(1)". Even so, I can't change the auto-generation of EntityFramework, of course.
So, is there anybody to help me out? Is there something I'm doing wrong here?

Viewing all articles
Browse latest Browse all 1451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>