EF 配置(SqlServer,Mysql)

DbProvider

Mysql

<system.data>
<
DbProviderFactories>
<
remove invariant="MySql.Data.MySqlClient"/>
<
add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory,MySql.Data"/>
</
DbProviderFactories>
</
system.data>

 

Connection String

Sqlserver

 

<connectionStrings>
    <add name="ConnectionStringName" 
connectionString
="Data Source=.;Initial Catalog=xxxx;Persist Security Info=True;User ID=xx;Password=xxx;Connect Timeout=120;"
providerName
="System.Data.SqlClient" /> </connectionStrings>

 

 

 

Mysql

<connectionStrings>
<
add name="ConnectionStringName" connectionString="Datasource=hostname;Database=schema_name;uid=username;pwd=Pa$$w0rd;" providerName="MySql.Data.MySqlClient"/>
</
connectionStrings>

 

Database Initializer

 

Sqlserver

 

 

    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, 
EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />

 

<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="Server=localhost; Database=ActivitySpread_Dev; User Id=zxx;Password=xxx; 
Integrated Security=False; MultipleActiveResultSets=True;" />

</parameters> </defaultConnectionFactory> </entityFramework>

 

 

 

Mysql

<configSections><section name="entityFramework" 
    type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, 
    EntityFramework, Version=5.0.0.0, Culture=neutral, 
    PublicKeyToken=b77a5c561934e089"/></configSections><entityFramework><contexts><context type="Namespace.YourContextName, AssemblyName"><databaseInitializer 
           type="Namespace.YourChosenInitializer, AssemblyName"></databaseInitializer></context></contexts><defaultConnectionFactory 
      type="MySql.Data.MySqlClient.MySqlClientFactory,MySql.Data"/></entityFramework>

 

posted @ 2013-11-05 10:42  JasNature  阅读(11778)  评论(0编辑  收藏  举报
我要赞个
我要评论
我要收藏