1

I have this Web.config

  <connectionStrings>
    <add name="AuthContext" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=mokey;Integrated Security=True" providerName="System.Data.SqlClient" />
   </connectionStrings>

and

Web.Release.config

  <connectionStrings>
    <add xdt:Transform="SetAttributes" xdt:Locator="Match(name)" name="AuthContext" providerName="MySql.Data.MySqlClient" connectionString="server=mysql2.gear.host;database=mokey;persistsecurityinfo=True" />
  </connectionStrings>

So I have two databases, local vs production.

Now when I run update-database local database is updated.

How do I run update-database for production database, that is migrate database to latest version?

1
  • 1
    Do you have AutomaticMigrationsEnabled enabled in your Configuration class? If yes, when you deploy to production it will update the production database to latest version Commented Aug 12, 2015 at 14:17

1 Answer 1

1

You may want to reconsider updating your PRODUCTION database with a code deployment. That's not what EF intended and a lot of DBA's will have issues with a direct update from code.

What we do is generate a script from our migrations that the DBA runs as described here: http://cpratt.co/migrating-production-database-with-entity-framework-code-first/#at_pco=smlwn-1.0&at_si=54ad5c7b61c48943&at_ab=per-12&at_pos=0&at_tot=1

You also have to consider what your database initializer is and set it to null or migratetolatestversion in production. You could also use migrate.exe in your build server to update your database.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.