查看: 2566|回复: 4
|
MVC5 + EF6 + MySQL Connector 6.8.3
[复制链接]
|
|
有没有人用着 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 就自己研究 |
|
|
|
|
|
|
|
发表于 24-2-2014 02:48 PM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 24-2-2014 10:26 PM
|
显示全部楼层
路过,N年前用过Expandable DBs/scale-out db instead of scale up/MSDTC就没碰了EF了。 |
|
|
|
|
|
|
|
发表于 9-9-2016 05:17 PM
|
显示全部楼层
请问ASP.NET 和 ASP.NET MVC 有什么不同?
|
|
|
|
|
|
|
|

楼主 |
发表于 9-9-2016 06:55 PM
|
显示全部楼层
ASP.Net 用 web form
ASP.Net MVC 用 MVC 
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|