将EntityFramework设置放到另一个配置文件中

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将EntityFramework设置放到另一个配置文件中相关的知识,希望对你有一定的参考价值。

我想划分我的web.config,有些部分可以使用像httphandler或appsettings这样的使用configSource属性进行划分。我想将实体框架设置分开到不同的config.file.Is这可能吗?

<httpHandlers configSource="ConfigurationFiles\Settings\Web.HttpHandlers.config" />

>  <entityFramework>
>     <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory,
> EntityFramework">
>       <parameters>
>         <parameter value="v11.0" />
>       </parameters>
>     </defaultConnectionFactory>
>     <providers>
>       <provider  invariantName="Oracle.DataAccess.Client" type="Oracle.DataAccess.EntityFramework.EFOracleProviderServices,
> Oracle.DataAccess.EntityFramework, Version=6.121.2.0, Culture=neutral,
> PublicKeyToken=89b483f429c47342" />
>       <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices,
> EntityFramework.SqlServer" />
>     </providers>   </entityFramework>
答案

是的,就像你为httpHandlers做的一样,例如:

<entityFramework configSource="ConfigurationFiles\Settings\EntityFramework.config" />

并在ConfigurationFiles\Settings\EntityFramework.config文件中:

<entityFramework>
    <!-- etc..... -->
</entityFramework>

以上是关于将EntityFramework设置放到另一个配置文件中的主要内容,如果未能解决你的问题,请参考以下文章

EntityFramework Code-First 简易教程-------领域类配置之Fluent API

IDEA内存设置

从另一个不工作的线程调用存储过程 c#, EntityFramework

Entity Framework 4.3 - TPH 映射和迁移错误

EntityFramework Code-First 简易教程-------一对一

无法在配置中设置ProviderService