日期:2014-05-20  浏览次数:20920 次

Entity Framework 4.1 Code First 是否支持Mysql
Entity Framework 4.1 Code First 是否支持Mysql??

我按照网上的例子(http://www.cnblogs.com/haogj/archive/2011/04/03/2004153.html)写了一个测试程序,如果使用Sql Server,程序可以成功创建数据表。

但若使用MySql数据库,就不行?

难道要安装别的东西嘛?

------解决方案--------------------
微软从来都是首先支持MSSQL。假如你要使用第三方数据库,那么需要这个数据库的厂商模仿微软的代码实现完全的EF支持。

从官方文档来看,MySQL厂商并没有EF 4.1的支持,http://dev.mysql.com/doc/refman/4.1/en/connector-net-visual-studio-entity-framework.html

也许是还在开发中。

其他公司的MySQL驱动似乎已经提供完整的EF 4.1支持了,但是额外收费,

http://www.devart.com/blogs/dotconnect/index.php/entity-framework-code-first-support-for-oracle-mysql-postgresql-and-sqlite.html

------解决方案--------------------
官方博客上有一段话:不知道具体是否涉及Mysql,你可以看看。不知你是否用的‘EF 4.1 Update 1’。
EF 4.2 Beta 1 Available

We recently posted about our plans to rationalize how we name, distribute and talk about releases. We heard a resounding ‘Yes’ from you so then we posted about our plans for releasing EF 4.2. Today we are making EF 4.2 Beta 1 available. 

EF 4.2 = Bug Fix + Semantic Versioning
When we released ‘EF 4.1 Update 1’ we introduced a bug that affects third party EF providers using a generic class for their provider factory implementation, things such as WrappingProviderFactory<TProvider>. We missed this during our testing and it was reported by some of our provider writers after we had shipped. If you hit this bug you will get a FileLoadException stating “The given assembly name or codebase was invalid”. This bug is blocking some third party providers from working with ‘EF 4.1 Update 1’ and the only workaround for folks using an affected provider is to ask them to remain on EF 4.1. So, we will be shipping this version to fix it, this will be the only change between ‘EF 4.1 Update 1’ and ‘EF 4.2’. Obviously a single bug fix wouldn’t normally warrant bumping the minor version, but we also wanted to take the opportunity to get onto the semantic versioning path rather than calling the release ‘EF 4.1 Update 2’.
---------------------------