8

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

No connection string named 'TechnicalAnalyzerEntities' could be found in the application config file.

The thing 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/ there is just one project in my solution (I search and the same error seems to appear when people have one project with the connection string and a startup project without, well not my case)

3/ this error seems not to prevent my project to run, nor Entity Framework to access the data and bind it to my treeview.

Actually the only issue is that there is this error showing in my error list and the MainWindow.xaml file (where the error is referenced) that can't show properly the custom control that then needs this connection string ==> cannot create an instance of "TreeviewSelector". The thing is that the custom control xaml file (TreeviewSelector.xaml as you guessed) is properly shown in the xaml editor.

This is not a dramatic error that prevents me to go forward on my project, but it is annoying to have errors and not to be able to properly use the xaml editor.

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

samuel guedon
  • 575
  • 1
  • 7
  • 21

3 Answers3

4

I've been there and struggled with that exact issue.

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

The NuGet wizard that sets up app.config is quite smart: if there are some bad settings in it already, it will remove them and add good entries.

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

Community
  • 1
  • 1
Contango
  • 76,540
  • 58
  • 260
  • 305
  • Well it doesn't worked. I remove EF5. installed EF6, delete my db model and regenerate it with the new EF, try to find and delete any references to the 5.0 (following the link you provided), try to minimize the amount of data in my app.config (based on an other EF6 project I have with proper app.config file), ... nothing worked – samuel guedon Jun 04 '15 at 23:24
2

Try reordering the sections in your app.config file. Sometimes, if the sections are in an unexpected order, they will generate a schema error on compile.

Base the ordering of the sections on a freshly generated app.config file using the wizards in Visual Studio for Entity Framework.

Contango
  • 76,540
  • 58
  • 260
  • 305
  • 1
    I actually tried something like this. and deleted the whole entries in my app.config + deleting the whole EF model and regenerate everything. – samuel guedon Jun 04 '15 at 22:55
  • Try upgrading to EF6 as per my answer above. The two versions are relatively close, so the code should still run fine. – Contango Jun 04 '15 at 22:58
1

Try closing all of the open files in your solution by pressing Ctrl-F4 repeatedly. Sometimes, this will clear any rogue errors generated at compile time.

There is a known bug in visual studio where xml files with an unexpected schema creates benign errors during a compile.

Contango
  • 76,540
  • 58
  • 260
  • 305
  • 1
    I tried rebuilding several times. Closing opening building and again and again. Copy on an other computer and open / build. Nothing worked – samuel guedon Jun 04 '15 at 22:56