Moving SDF database from app folder to user folder due to Windows 7 UAC?

I am using SQL Server CE 4.0 for my WPF (MVVM) project and during development the database is in the same folder as my application, so I have the following connection string in my APP.CONFIG file:

<configuration>
<add name="DatabaseEntities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlServerCe.4.0;provider connection string=&quot;Data Source=Database.sdf&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
</configuration>

      

Then I created a Windows Installer (MSI) and everything is fine on Windows XP ...

However, when I go to WINDOWS 7, the database (which is deployed in the installation folder) is not available (UAC). So it looks like I need to move the SDF to a different location ...?

I am assuming it should go under Users ... \ AppData \ Local \ Model \ Database.SDF correct? Or is there another suitable place for such files?

Also, I have absolutely no idea how to change my ConnectionString to point to this new location (it's encoded in the APP.CONFIG file).

Any suggestions and help would be much appreciated.

Thank,

+3


source to share


1 answer


You should read the following article about the recommended folders for application data on Windows 7 machines.



As for your .config file, which is a standard XML file, most professional configuration tools support importing and updating its content during the installation process. For example, in the following article, you can see how to import and edit during installation and XML in Advanced Installer .

+4


source







All Articles