title: EF5 generates SQL Server CE constraints with dot in name
body: <p>I am building a .NET disconnected client-server application that uses Entity Framework 5 (EF5) to generate a SQL Server CE 4.0 database from POCOs. The application allows the user to perform a bulk copy of data from the network SQL Server into the client's SQL Server CE database. This is very (VERY) slow, due to the constraints and indexes created by EF5. Temporarily dropping the constraints and indexes will reduce the 30-minute wait to 1 minute or less.</p>
  
  <p>Before starting the bulk copy, the application executes queries to drop the constraints and indexes from the SQL Server CE tables. However, the commands fail, because EF5 created constraint names include the table schema name, dot, and table name. The dot in the constraint name is causing the drop command to fail, due to a parsing issue.</p>
  
  <p>For example, POCO <code>Customer</code> creates table <code>dbo.Customer</code> with the primary key constraint <code>PK_dbo.Customer_Id</code>. The database performs as expected. </p>
  
  <p>However, upon executing non-query:</p>
  
  <pre><code> ALTER TABLE Customer DROP CONSTRAINT PK_dbo.Customer;
  </code></pre>
  
  <p>SQL Server Compact ADO.NET Data Provider returns an error:</p>
  
  <blockquote>
    <p>There was an error parsing the query.<br>
    [ Token line number = 1, Token line offset = 57, Token in error = . ]</p>
  </blockquote>
  
  <p>Of course, using a secondary <code>DataContext</code> object that does not have foreign keys generate the database without the constraints, and then add them later works; but, that requires maintaining two <code>DataContext</code> objects and hopefully not forgetting to keep both updated. Therefore, I am looking for one of two solutions:</p>
  
  <ol>
  <li><p>Compose the DROP statement in such a way that the . character is parsed</p></li>
  <li><p>Prevent EF5 from using the . character in the constraint and index names</p></li>
  </ol>
  
  <p>Thank you in advance for your help!</p>