title: Update SQL Server CE database (.sdf) from 3.5 to 4.0
body: <p>I need to upgrade a SQL Server Compact database from 3.5 to 4.0 version. I am using linq-to-sql</p>
  
  <p>I tried some things that I found on stackoverflow, that did not help:</p>
  
  <ol>
  <li><p>I tried <code>Add 4.0 connection</code> dialog (no error messages, bak file was created)</p></li>
  <li><p>I tried upgrading in code: (no error messages)</p>
  
  <pre><code>System.Data.SqlServerCe.SqlCeEngine engine= new System.Data.SqlServerCe.SqlCeEngine("Data source = ...");
  engine.Upgrade();
  </code></pre></li>
  <li><p>I checked for database corruption (system returned that there are no corruption problems)</p>
  
  <pre><code>System.Data.SqlServerCe.SqlCeEngine engine= new System.Data.SqlServerCe.SqlCeEngine("Data source = ...");
  engine.Verify();
  </code></pre>
  
  <p>After these operations I wanted to recreate dbml file - I received error message </p>
  
  <blockquote>
    <p><em>Incompatible Database Version (..) DB version 4000000, Requested version 3505053 (..)</em></p>
  </blockquote></li>
  <li><p>In debug mode I checked <code>db.Connection.ServerVersion</code> = returns 3.5.8080.0</p></li>
  <li><p>In database connection properties version is 4.0.8876.1</p></li>
  </ol>
  
  <p>Any suggestions?</p>