I am using C# WPF EF6.0 and SQL Server Express for final program.
I have created a setup file with Advanced installer that creates database via script and SQL Server Express in
C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA
and I have changed my string connection from
<add name="MyDBEntities"
connectionString="metadata=res://*/MyDBModel.csdl|res://*/MyDBModel.ssdl|res://*/MyDBModel.msl;provider=System.Data.SqlClient;provider connection string="data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\MyDB.mdf;integrated security=True;connect timeout=30;MultipleActiveResultSets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
To this
<add name="MyDBEntities"
connectionString="metadata=res://*/MyDBModel.csdl|
res://*/MyDBModel.ssdl|
res://*/MyDBModel.msl;
provider=System.Data.SqlClient;
provider connection string="
Data source=.\SQLExpress;
integrated security=True;
MultipleActiveResultSets=True;
Initial Catalog=MyDB;
App=EntityFramework""
providerName="System.Data.EntityClient" />
I have installed .net Framework 4.5 and SQL Server 2012 sp1 v11.0.300 that I have used in Visual Studio 2013
When I install my program, everything works, but when I run my program it stopped working at first launch. I think the connection string has a problem. If I click debug in Visual Studio, I see this error
An unhandled exception of type 'System.InvalidOperationException' occurred in EntityFramework.dll.Additional information: No connection string named 'MyDBEntities' could be found in the application config file.
Finally I couldn't create a setup file with Advanced Installer
.
But I created it by Install Shield
.
My problem was insert or delete or edit from database.
I installed my program in other drive and my problem solved.
The reason was a joke that program files in C
is readonly
.