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>
上一篇:webrtc 的回声抵消(aec、aecm)算法简介(转)


下一篇:.NET技术-.NET各大网站-编程技术网址