mysql 使用EF6.0CodeFirst

工具:vs2012+.net4.5+MariaDb10.04+EF6.0+mysql-connector-net-6.8.0(还没正式发布)

配置文件

  <?xml version="1.0" encoding="utf-8"?><!--有关如何配置 ASP.NET 应用程序的详细信息,请访问
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>
  <system.data>
<DbProviderFactories>
<!-- 不设置这里会提示找不到提供程序--> <add name="MySQL" description="ADO.Net driver for MySQL" invariant="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data"/> </DbProviderFactories> </system.data> <entityFramework>
<!-- 默认设置的sql--> <defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity.EF6"> <parameters> <parameter value="v11.0" /> </parameters> </defaultConnectionFactory> <providers> <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" /> </providers> </entityFramework> <connectionStrings> <add name="mysqlConn" connectionString="DataSource=localhost;DataBase=mysql;uid=root;pwd=410115424" providerName="MySql.Data.MySqlClient" /> </connectionStrings> </configuration>

配置好就可以使用CodeFirst 了

posted @ 2013-10-24 14:34  2GyAn  阅读(1741)  评论(4编辑  收藏  举报