EntityFramework在不同数据库下的配置

6951人阅读 评论(0) 收藏 举报
分类:

EntityFramework默认只支持SQLServer数据库,如果想要支持其他数据库,要安装相应的插件。

如支持Oracle,要安装Oracle Data Access Components (ODAC),支持MySQL要安装mysql-connector-net-6.4.6等

下面列举下3种数据库下的配置:

1.SQLServer:

<connectionStrings>
    <add name="EntityDesignEntities" connectionString="metadata=res://*/EntityDataModel.EntityDesign.csdl|res://*/EntityDataModel.EntityDesign.ssdl|res://*/EntityDataModel.EntityDesign.msl;provider=System.Data.SqlClient;provider connection string="data source=.;initial catalog=DevBase;persist security info=True;user id=sa;password=xxx;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
  </connectionStrings>


 

2.Oracle:

<connectionStrings>
    <add name="EntityDesignEntities" connectionString="metadata=res://*/EntityDataModel.EntityDesign.csdl|res://*/EntityDataModel.EntityDesign.ssdl|res://*/EntityDataModel.EntityDesign.msl;provider=Oracle.DataAccess.Client;provider connection string="data source=xe;password=xxx;persist security info=True;user id=sa"" providerName="System.Data.EntityClient"/>
  </connectionStrings>


 

3.MySQL:

<connectionStrings>
    <add name="EntityDesignEntities" connectionString="metadata=res://*/EntityDataModel.EntityDesign.csdl|res://*/EntityDataModel.EntityDesign.ssdl|res://*/EntityDataModel.EntityDesign.msl;provider=MySql.Data.MySqlClient;provider connection string="server=localhost;user id=sa;password=xxxx;persist security info=True;database=world"" providerName="System.Data.EntityClient"/>
  </connectionStrings>


 

1
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:181137次
    • 积分:2205
    • 等级:
    • 排名:千里之外
    • 原创:45篇
    • 转载:1篇
    • 译文:0篇
    • 评论:149条
    最新评论