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="data source=PSYKOTROPYK-PC\PSYKOTROPYK;initial catalog=TechnicalAnalyzer;persist security info=True;user id=***;password=***;network library=dbnmpntw;MultipleActiveResultSets=True;App=EntityFramework"" 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
To define the connection strings in appsettings. json it is important to specify it in the right section of the JSON structure. Now we can read it in our code by calling the GetConnectionString method in the Microsoft. Extensions.
After opening the web. config file in application, add sample db connection in connectionStrings section like this: <connectionStrings>
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With