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>
如果觉得本文适合您且对您有帮助,请一定记得点推荐哟!
作者:
JasNature 出处: http://NatureSex.cnblogs.com 本文版权归作者和博客园共有,欢迎转载,但必须保留此段声明,且在文章页面明显位置给出原文连接。 如果本文有什么不妥或者错误的地方,请您一定要在评论中指出,以免误人子弟!非常感谢您的不吝赐教! | |||