0

I'm working on MVC, AngularJS and EntityFramework project in VS2015. We are team of multiple developers. The code is shared in source control. But the real issue is I'm not much experienced with Code Migrations. Whenever I start my work and get latest on the source control, I have to update the database to add the new migrations in my local db. But whenever I try

"update-migrations -targetmigration:xxx"

script, it always throws me an error. I also tried this steps showing in this page: Reset Entity-Framework Migrations but it didn't work.

Also my Configuration class says this:

public Configuration()
        {
            AutomaticMigrationsEnabled = false;
            ContextKey = "WebAccounts";
        }

Which I'm not supposed to change anything.

Is there any simple and straight forward way or steps to follow?

Thanks.

Community
  • 1
  • 1
Mansang
  • 15
  • 6
  • "it always throws me an error" -> What's the error? – ESG May 22 '16 at 16:43
  • Read this on working with migrations in a team environment: https://msdn.microsoft.com/en-US/data/dn481501 – Steve Greene May 22 '16 at 16:47
  • @ESG - Different errors everytime.. So solutions I have seen which suggests the database tables to be delete and initialize them again.. but I don't want to do it as it will delete the data as well. Curretly I was trying to add one migration script using update-database -targetmigration:scriptname, "but it says the table already exists". sotimes throws an error about foreign key constraints. – Mansang May 22 '16 at 16:52
  • @Steve: Helpful article, but will take time to understand the whole workflow. – Mansang May 22 '16 at 17:42
  • Based on your comments you are running into the exact problems this article describes. If you are going to have multiple developers changing schema then you need a baseline migration (or rollback). – Steve Greene May 23 '16 at 13:09

0 Answers0