我目前有一個應用程序,它首先使用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