0

I am working on a c# web application. currently i am testing on my local host as in visual studio mvc c# local host. I have done several additions and created new tables; I used migration. each time i enable-migration, then add-migration, then update database. now here is my question. all of this migration happened on my local host, now on production, after i have published to my www root on production, will this changes happen automatically, will i lost the production database content when i copy over from local host to production?

basically all i want is the new table fields and structure NOT content to be published or copied over to production.

thanks

3
  • Poss duplicate or this Commented Aug 18, 2013 at 2:44
  • DonA actually it is not a duplicate. I am working in C# MVC and it says to do migration when I am publishing, the links you posted has nothing to do with migration. thanks anyways. Commented Aug 18, 2013 at 3:42
  • I was thinking that it solves the issue, but your needs are more specific. Commented Aug 18, 2013 at 3:44

2 Answers 2

2

Assuming you are using EntityFramework.

now on production, after i have published to my www root on production, will this changes happen automatically?

This actually depends on your configuration. By default it does not unless you told it to. If you want to automatically upgrade the database applying any pending migrations register MigrateDatabaseToLatestVersion database initializer.

will i lost the production database content when i copy over from local host to production?

By the word content if you mean data and by copy over if you mean applying the migration then EF does not have a native data motion support yet. So you should not lose your content's integrity. Though you may execute custom sql inside your migrations if needed. Sql() is the function for that.

Bottom line, if you do not use DropCreateDatabaseIfModelChanges or DropCreateDatabaseAlways in the production code you are relatively safe.

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

Comments

0

As far as I know, the data don't change if you don't specify it, but you should try to create a staging environment with a copy or restore of production database to test the migration success.

Anyway, depending on the migration mode you are using, the production database will be affected. Take a look at this MSDN link for further info.

This link for a list of EF commands that can be helpful.

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.