【发布时间】:2018-08-28 12:47:25
【问题描述】:
我已经在 Visual Studio 中通过NuGet Package Manager 安装了Entity Framework。在我安装这个包的每个项目中,都会出现一个app.config 文件,看起来就像这样:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<add name="DatabaseContext" connectionString="data source=(LocalDb)\MSSQLLocalDB;initial catalog=Namespace.ContextName;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
我想知道这些信息是否仅在启动项目(和单元测试项目)中是必需的。我可以从只使用DbContext 的类库项目中删除app.config 文件吗?
【问题讨论】:
-
你有没有试过删除它,看看会发生什么?
-
我还做不到。一旦我尝试过,我会发布我的结果,当时没有人提供答案。
标签: c# visual-studio entity-framework nuget app-config