title: Deploying entity framework code first with production database
body: <p>I've developed a pretty simple web app using entity framework code first. I realized after hours of frustration that even though localdb is SQL Server Express it is actually not meant to be used with production when using 'publish' (the publish wizard). FYI I'm using EF 6.1.3, SQL Server 2014, VS 2013, and IIS 7.</p>
  
  <p>If I understand correctly, when you click publish with localdb, all you're really doing is copying your localdb database to your IIS 7 server. I couldn't figure out why that when I updated my lodaldb database through VS migrations that my production server database wasn't being updated. I understand (and believe now) that it's actually two different instances of localdb, and hence not the same data.</p>
  
  <p>OK whatever - I'm done with localdb and I created a real SQL Server 2014 db on my machine. I've googled for hours and can't figure out what to do now. I have some questions:</p>
  
  <ol>
  <li><p>How do I manage this new database using EF? For instance, suppose I want to add a new column. First I add it to my localdb, do some testing, and do the migration using Add-Migration blah then Update-Database... Do I then have to generate a SQL script using VS and then manually run that on the production DB server?</p></li>
  <li><p>I know this isn't great, but instead of using local DB with entity framework, can I just attach EF to a real staging SQL Server database (a test one) and skip all this localdb bull****? Then could I manage it using code-first migrations and keep everything in sync?</p></li>
  <li><p>Am I supposed to use an Initializer? I've read conflicting reports about whether to use these or not for a production db (like this one)</p>
  
  <p>public class PricedNotesInitializer: MigrateDatabaseToLatestVersion&lt;...,...>      {
  }</p></li>
  </ol>
  
  <p>It's frustrating that the only way I learn about this stuff is through blog posts from other people frustrated. I don't understand why the documentation is so garbage.</p>
  
  <p>Thanks for your help and sorry for the rant.</p>