EF 数据库节点配置(SqlServer,Mysql)_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > EF 数据库节点配置(SqlServer,Mysql)

EF 数据库节点配置(SqlServer,Mysql)

 2013/11/5 11:36:42  NatureSexy  博客园  我要评论(0)
  • 摘要:DbProviderMysql<system.data><DbProviderFactories><removeinvariant="MySql.Data.MySqlClient"/><addname="MySQLDataProvider"invariant="MySql.Data.MySqlClient"description=".NetFrameworkDataProviderforMySQL"type="MySql.Data
  • 标签:Server SQLSERVER 配置 数据库 数据 SQL 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>

 

发表评论
用户名: 匿名