1

I've created a project using EF Version 6.0, with settings of AutomaticMigrationsEnabled = true;

Which worked fine, i could able to deploy in production server on first time, It created desire database tables.

Now for second update, I've get script out from migration so that i can able to run in production server. but i tried many Package Manager commands, but it does creating empty .sql files.

My second Migration has name "201601181549424_Version-1.2.0", i used following sequence of steps and commands to generate .sql file.

  • Added desire data classes (which will be creating tables in database) and MVC views and controller.
  • Run Package Manger Command is "ADD-MIGRATION Version-1.2.0" has created 201601181549424_Version-1.2.0" file in Migration folder
  • Than "UPDATE-DATABASE" - has updated local database, check everything works fine.
  • Than "UPDATE-DATABASE -Script" - has created empty.sql file. I am looking to get sql file with creation of database tables in sql file.

Can you please help me understand how i can deploy this in production database.

Thanks,

3
  • change the connection string of your web.config to the production database and then run "update-database". That's the easiest way in my opinion Commented Jan 18, 2016 at 18:21
  • I would like to keep track of every changes made in database, so i like to run .sql scrip separately Commented Jan 18, 2016 at 19:38
  • you could use "update-database -verbose" and then copy the generated sql. I'll see if there's a better approach Commented Jan 18, 2016 at 19:43

1 Answer 1

1

I figured out by this way..

Make desire changes to model, (INSERT OR UPDATE MODEL)

  1. Add-Migration
  2. Update-Database -Script

(Which will create script and can store for QA or production deployment purpose)

  1. Update-Database

(Above command will update model in to local database)

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.