Reputation: 14195
Inside my DAL project I have repositories which I consume from ui. I've refactor project a bit and now on gather data from repository I'm getting error
"No connection string named 'MyAppDbContext' could be found in the application config file."
My App.config on same project (DAL) where repository lives have following context
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<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>
<connectionStrings>
<add name="MyAppDbContext" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=MyApp.DAL.MyAppDbContext;Integrated Security=True;AttachDBFilename=MyApp.DAL.MyAppDbContext.mdf" providerName="System.Data.SqlClient" />
</connectionStrings>
<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>
</configuration>
I actually have two questions:
Upvotes: 2
Views: 763
Reputation: 5147
Try adding connection string to the configuration file of the consuming project, not the DAL project.
Upvotes: 1