1

When I make changes to my database, my other database will get out of date. When I publish the application, the application will throw the error that a certain constraint needs a certain column, which doesn't exist etc etc, so the logical conclusion is that the migrations are not applied on the second database. What can I do to keep track of which migration is applied to which database? This is what I now have in my Configuration.cs:

public class Configuration : DbMigrationsConfiguration<JonepCRM.Model.JonepCRMDb>
{
    public Configuration()
    {
        AutomaticMigrationsEnabled = true;
        AutomaticMigrationDataLossAllowed = true;
    }
}

So as you can Imagine, everything just works "automatically" without me having to track stuff. But all that changed after introducing the test database my testers work on! :)

So I found this: How to delete and recreate from scratch an existing EF Code first database

I suppose that should be the easy way out, since I don't care much about the data in the development database. But I was wrong there. The package manager console, in bright red letters, tells me:

No migrations configuration type was found in the assembly 'JonepCRM'. (In Visual Studio you can use the Enable-Migrations command from Package Manager Console to add a migrations configuration).

So I've probably made a lot of mistakes sorting out how to setup my model and corresponding database, even though I figured I had found the most easy way where everything just happened automatically.

I actually chose this setup (back when it was one database) because this migrations thing went south very badly and had me puzzled for hours at a time to get the application running at every change to the model. I wouldn't want to return to that situation.

Anyone have some advice for me? Basics are fine, but specifically the solution for my "2 database"-problem.

Community
  • 1
  • 1
Jon Koeter
  • 1,005
  • 2
  • 16
  • 25

0 Answers0