您好我刚开始使用实体并从数据库中创建模型,但是当我选择它时会出现以下错误:
在。中找不到名为'ninja_crmEntities'的连接字符串 应用程序配置文件。
带有实体的项目是库类,app.config看起来像:
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<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.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient"
type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<add name="ninja_crmEntities"
connectionString="metadata=res://*/ninja_entities.csdl|res://*/ninja_entities.ssdl|res://*/ninja_entities.msl;provider=System.Data.SqlClient;provider connection string="data source=localhost;initial catalog=ninja_crm;persist security info=True;user id=sa;password=elo320;MultipleActiveResultSets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
</connectionStrings>
答案 0 :(得分:2)
如果项目是库,它不使用它自己的App.config,而是项目中实际执行的那个。该配置中的EF设置也是如此吗?