Error: there is no connection string in the application configuration file ... but there is one

I have the following error when I try to build my solution:

Could not find connection string named "TechnicalAnalyzerEntities" in application configuration file.

The fact is that:

1 / there is one:

<connectionStrings> <add name="TechnicalAnalyzerEntities" connectionString="metadata=res://*/Data.Database.TAdb.csdl|res://*/Data.Database.TAdb.ssdl|res://*/Data.Database.TAdb.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=PSYKOTROPYK-PC\PSYKOTROPYK;initial catalog=TechnicalAnalyzer;persist security info=True;user id=***;password=***;network library=dbnmpntw;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> </connectionStrings> 

2 / in my solution there is only one project (I'm looking for the same error when people have one project with a connection string and a start project without, well, not in my case)

3 / this error does not seem to prevent my project from starting, as well as the Entity Framework for accessing data and binding to my tree structure.

Actually, the only problem is that this error appears in my list of errors and in the MainWindow.xaml file (where the error is mentioned), which cannot correctly display the user control, which then needs this connection string ==> can not create instance of "TreeviewSelector". The fact is that the xaml user control (TreeviewSelector.xaml, you guessed it) displays correctly in the xaml editor.

This is not a dramatic mistake that prevents me from moving forward on my project, but it annoys me that I have errors and the inability to use the xaml editor correctly.

NB: A few other points that may be of interest: 1 / I am using Entity Framework 6.0 2 / The project is on my laptop and the database on my desktop 3 / Blend shows the same error MainWindow.xaml 4 / If I put a copy of my project to my desktop (so on the same system as my database), I have the same problem

+8
c # wpf entity-framework connection-string
source share
3 answers

I was there and struggled with this exact problem.

The solution is to add Entity Framework 6 to your application using NuGet . This will automatically generate the correct connection string for you, and it will automatically configure your app.config .

The NuGet wizard creating app.config is pretty smart: if it already has some bad settings, it will delete them and add some good entries.

See my answer here: Upgrading from Entity Framework 5 to 6 .

+4
source share

Try reordering the sections in the app.config file. Sometimes, if partitions are in an unexpected order, they will generate a schema error during compilation.

Use the wizards in Visual Studio for Entity Framework to adjust the partition order to the newly created app.config file.

+2
source share

Try closing all open files in your solution by pressing Ctrl-F4 several times. Sometimes this fixes any rogue errors generated during compilation.

A well-known bug in visual studio, where xml files with an unexpected layout create benign errors at compile time.

+1
source share

All Articles