为什么 <entityFramework> 和 <configSections> 标签出现在我的 web.config 文件中?
Why did <entityFramework> and <configSections> tags appear in my web.config file?
为什么这段代码会出现在我的 web.config 文件中?当我创建我的 ADO.NET 实体数据模型时它不存在,那么是什么事件触发了此代码的生成?
<configSections>
<section name="entityFramework"
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false"/>
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb"/>
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
</providers>
</entityFramework>
Entity framework 软件包在多个实例中自动安装。例如,当您使用现成的模板创建项目时,例如启用了个人身份验证的 ASP.Net MVC 项目。因为在那种情况下,应用程序将与 EF 绑定以处理所有与身份验证相关的数据库交互。
其次,如果您添加一个模型 class 和一个带有脚手架的控制器以使用 Entity Framework ("MVC 5 Controller with views, using Entity Framework") 生成视图。在这种情况下,如果 entity framework 尚未配置,脚手架机制将完成该工作。结果我们在 web.config 中看到了所有 EF 相关的配置和项目中的 DLL 引用。当我们在 visual studio 中开始处理这些新项目模板时,这会导致一些混乱。
为什么这段代码会出现在我的 web.config 文件中?当我创建我的 ADO.NET 实体数据模型时它不存在,那么是什么事件触发了此代码的生成?
<configSections>
<section name="entityFramework"
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false"/>
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb"/>
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
</providers>
</entityFramework>
Entity framework 软件包在多个实例中自动安装。例如,当您使用现成的模板创建项目时,例如启用了个人身份验证的 ASP.Net MVC 项目。因为在那种情况下,应用程序将与 EF 绑定以处理所有与身份验证相关的数据库交互。 其次,如果您添加一个模型 class 和一个带有脚手架的控制器以使用 Entity Framework ("MVC 5 Controller with views, using Entity Framework") 生成视图。在这种情况下,如果 entity framework 尚未配置,脚手架机制将完成该工作。结果我们在 web.config 中看到了所有 EF 相关的配置和项目中的 DLL 引用。当我们在 visual studio 中开始处理这些新项目模板时,这会导致一些混乱。