我目前有一个应用程序,它首先使用EF数据库,它是针对SQL Server数据库构建的。我想允许连接到MSSQL或MySQL的能力。实体框架数据库首先与MySQL和MS SQL
我认为通过使用EF我可以更改连接字符串,使其指向的MySQL,但是,当我这样做,我得到以下错误:
Unable to cast object of type 'MySql.Data.MySqlClient.MySqlConnection' to type 'System.Data.SqlClient.SqlConnection'.
使EF工作需要哪些其他措施与MySQL和MSSQL。
更新: 连接字符串:
<add name="EntityConnString" connectionString="metadata=res://*/Entities.csdl|res://*/Entities.ssdl|res://*/Entities.msl;provider=MySql.Data.MySqlClient;
provider connection string="server=localhost;User Id=root;password=password;Persist Security Info=True;database=mydb;Connection Protocol=NamedPipe"" providerName="System.Data.EntityClient" />
你可以发布你的连接字符串与虚拟数据吗? – 2011-06-06 04:43:02
添加了连接字符串。 – Omar 2011-06-06 05:47:21
您是否对生成的代码进行了任何更改?你的tt文件或一切都是默认的?你的连接字符串很好。但是也可以看看你的edmx,它可能包含对存储名称空间(ssdl)中的mssql的一些引用。 – 2011-06-06 06:05:48