ef mysql配置文件_配置文件设置

配置文件设置Configuration File Settings

10/23/2016

本文内容

实体框架允许在配置文件中指定多个设置。Entity Framework allows a number of settings to be specified from the configuration file. 在常规 EF 中,遵循 "约定 over 配置" 原则:在此文章中讨论的所有设置都有默认行为,你只需考虑在默认不再满足你的要求时更改设置。In general EF follows a ‘convention over configuration’ principle: all the settings discussed in this post have a default behavior, you only need to worry about changing the setting when the default no longer satisfies your requirements.

Code-Based 替代方法A Code-Based Alternative

还可以使用代码应用所有这些设置。All of these settings can also be applied using code. 从 EF6 开始,我们引入了 基于代码的配置,它提供了一种从代码应用配置的集中方式。Starting in EF6 we introduced code-based configuration, which provides a central way of applying configuration from code. 在 EF6 之前,仍可以从代码应用配置,但需要使用各种 Api 来配置不同的区域。Prior to EF6, configuration can still be applied from code but you need to use various APIs to configure different areas. 配置文件选项允许在部署期间轻松地更改这些设置,而无需更新代码。The configuration file option allows these settings to be easily changed during deployment without updating your code.

"实体框架配置" 部分The Entity Framework Configuration Section

从 EF 4.1 开始,你可以使用配置文件的 appSettings 节为上下文设置数据库初始值设定项。Starting with EF4.1 you could set the database initializer for a context using the appSettings section of the configuration file. 在 EF 4.3 中,我们引入了自定义 entityFramework 部分来处理新设置。In EF 4.3 we introduced the custom entityFramework section to handle the new settings. 实体框架仍将识别使用旧格式设置的数据库初始值设定项,但建议在可能的情况下移动到新的格式。Entity Framework will still recognize database initializers set using the old format, but we recommend moving to the new format where possible.

安装 EntityFramework NuGet 包时, entityFramework 节会自动添加到项目的配置文件中。The entityFramework section was automatically added to the configuration file of your project when you installed the EntityFramework NuGet package.

type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

连接字符串Connection Strings

本页提供了 有关实体框架如何确定要使用的数据库的更多详细信息,包括配置文件中的连接字符串。This page provides more details on how Entity Framework determines the database to be used, including connection strings in the configuration file.

连接字符串位于标准 connectionStrin

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值