title: WP 7.1.1 Access to the database file is not allowed
body: <p>My environment Windows 8 Pro with Visual Studio 2010 Ultimate with WP 7.1.1 SDK installed.</p>
  
  <p>I have a WP 7.1.1 application with a SQL CE database. There are 2 databases, the one that comes with the initial package and another stored in Isolated Storage. On Application_Launching the code compares the version of both databases and if the one from the package is greater it replaces the one from Isolated Storage. <strike>On the first run of the app with the simulator closed, the app starts fine and copies the database to isolate storage. On the second run</strike> The following code:</p>
  
  <pre><code>using (SportsDataContext db = new SportsDataContext(DBConnectionString))
  {
    var setting = db.Settings.Where(s =&gt; s.SettingID == (Int16)Settings.DatabaseVersion).SingleOrDefault();
    if (setting == null)
      return false;
    newVersion = setting.Value;
  }
  </code></pre>
  
  <p>Throws the exception:</p>
  
  <blockquote>
    <p>Access to the database file is not allowed. [ 1981,File name = \Applications\Install\{GUID}\Install\{FileName}.sdf,SeCreateFile ]</p>
  </blockquote>
  
  <p>Also, leaving the emulator running and uninstalling the app and re running it makes it work.</p>
  
  <p>UPDATE
  The reason it works on the first run is because the code above is not executed (on purpose). Running it again makes the code above run and bomb.</p>
  
  <p>This used to work fine before on Windows 7 and without VS 2012. What might be causing the problem?</p>
  
  <p>UPDATE
  I reverted all my changes back prior to making any changes with my new Windows 8 setup and it works as expected. As soon as I open the sdf file with VS 2010 using Server Explorer and modify it I get the same problem when debugging the app. Weird!</p>