|
|
有没有人用着 MVC5 + EF6 + MySQL Connector 6.8.3?
最近再研究着,现在可以了。
如果要将 MVC3/MVC4 upgrade 去 MVC5,我建议 create 新的 MVC5 project,然后将旧 project 的 Controllers, Models & Views copy 去新的 project 比较好。
如果你还是要接受挑战,可以参考以下的教程
http://www.asp.net/mvc/tutorials ... mvc-5-and-web-api-2
如果 create 新的 MVC5 project,就去 Nuget download MySQL.Data, MySQL.Data.Entity.EF6 & MySQL.Web,然后记得去 wen.config 修改几样东西。
1. ConnectionString - 要注明 provider- <connectionStrings>
- <add name="adinggro" connectionString="server=localhost;User Id=root;password=password;database=db;" providerName="MySql.Data.MySqlClient" />
- </connectionStrings>
复制代码 2. 原本的 EntityFramework 拿掉,改成这样- <entityFramework>
- <defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity.EF6" />
- <providers>
- <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
- </providers>
- </entityFramework>
复制代码 3. 记得加 MySQL runtime,如果没有自动加,不然用不到 Context or Entity- <dependentAssembly>
- <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-6.8.3.0" newVersion="6.8.3.0" />
- </dependentAssembly>
复制代码 教程如下
* 如果用 Nuget 就不用 step 1,2,3 & 4
http://www.nzmk.com/Blogs/BlogsV ... ch-using-MySQL.aspx
我只用 Context 而已,没有用 Entity Model,所以如果要用到 Entity Model 就自己研究 |
|