I am using SQL Server CE 4.0 for my WPF (MVVM) project and during development the database is located in the same folder as my application – so in my APP.CONFIG file I have the following connection string:
<configuration>
<add name="DatabaseEntities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlServerCe.4.0;provider connection string="Data Source=Database.sdf"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
I then created a windows installer (MSI) and everything is perfect in Windows XP …
However when I move to WINDOWS 7 the Database (which is deployed in the installation folder) is not accessible (UAC). So it looks like I need to move the SDF somewhere else…?
I assume it should go under Users…\AppData\Local\Model\Database.SDF right? Or is there another more appropriate location for such files?
Also, I have absolutly no clue how to change my ConnectionString to point to this new location (it is harded coded in the APP.CONFIG file).
Any suggestions and help would be much appreciated.
Thanks,
You should read the following article about the recommended folders for application data on Windows 7 machines.
In what regards your .config file, which is a standard XML file, most professional setup authoring tools have support for importing it and updating its contents during the install process. For example, in the following article you can see how you can import and edit at install time and XML in Advanced Installer.