title: Problem connecting to database - user instance and Entity Framework issue
body: <p>I've created an entity model file (.edmx) based on an .mdf file in my asp.net application, placed in my <code>App_Data</code> Folder.</p>
  
  <p>first of all my connection string, created by the entity framework wizard : </p>
  
  <pre><code>&lt;connectionStrings&gt;
      &lt;add name="Sales_DBEntities" 
          connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string='data source=.\SQLEXPRESS;attachdbfilename=&amp;quot;c:\users\ext\documents\visual studio 2010\Projects\WebProject_A\WebProject_A\App_Data\Sales_DB.mdf&amp;quot;;integrated security=True;USER INSTANCE=TRUE;multipleactiveresultsets=True;App=EntityFramework'" 
          providerName="System.Data.EntityClient" /&gt;
  &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>The above is placed in an <code>app.config</code> file created by the wizard. </p>
  
  <p>I've copied the same connection string to the <code>web.config</code> file as well (I'm not sure if this is necessary).</p>
  
  <p>I've come across two problems when attempting to later run the same application on a my machine (I've created the application on a different machine).</p>
  
  <p>The first was regarding the user instance:</p>
  
  <blockquote>
    <p>Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed</p>
  </blockquote>
  
  <p>The first thing I don't really comprehend is what a user instance actually defines.</p>
  
  <p>According to MSDN :</p>
  
  <blockquote>
    <p><em>A user instance is a separate instance of the SQL Server Express Database Engine that is generated by a parent instance</em></p>
  </blockquote>
  
  <p>Is my local database considered a user instance ? </p>
  
  <p>I would really like some clarification on the matter because I came across posts suggesting 
  to mark it as False, and the reason was not clear to me .</p>
  
  <p><a href="https://stackoverflow.com/questions/14209/system-data-sqlclient-sqlexception-failed-to-generate-a-user-instance-of-sql-ser">another post on this matter</a></p>
  
  <p>From there I came across another solution that explains that for this problem you need to 
  enable user instance in the SQL Server on your machine.</p>
  
  <p><a href="http://aspdotnetfaq.com/Faq/fix-error-Failed-to-generate-a-user-instance-of-SQL-Server-due-to-a-failure-in-starting-the-process-for-the-user-instance.aspx" rel="nofollow noreferrer">The Fix</a></p>
  
  <p>I've done what was explained in that post  </p>
  
  <p>but now I've come across a new problem :</p>
  
  <blockquote>
    <p>An attempt to attach an auto-named database for file (Full Path to my app_data\my.mdf file)  A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.</p>
  </blockquote>
  
  <p>I've already attempted to delete all the files under </p>
  
  <pre><code> C:\Documents and Settings\(your user account name)\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS
  </code></pre>
  
  <p>and rebooting like suggested in other posts, but still I can't find a clear solution for this problem.</p>
  
  <p>I know this is a long post but any help would be appreciated </p>
  
  <p>thanks in advance. </p>