Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Disable Database Migrations #188


User avatar
0
clientfocusdev created

After importing the migrations from Zero, I need to manually make the EF model and have it not update my database.

Running a working Zero install after my model changes and I got

System.InvalidOperationException: The model backing the 'DbContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).

I cannot chance migrating into my existing schema. I've had this before in other APB projects and added,

Database.SetInitializer<DbContext>(null);

into the DbContext constructor.

Now I am stuck with an error,

System.ApplicationException: Filter name MustHaveTenant not found

Do I need to create a custom DbInitializer that deals with these new Zero Filters?


3 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    I just added

    Database.SetInitializer<TestProjDbContext>(null);
    

    to PreInitialize method of DataModule class and it worked.

    Have you overrided OnModelCreating or Initialize methods of your DbContext also? If so, call base methods as first line.

  • User Avatar
    0
    clientfocusdev created

    <cite>hikalkan: </cite>

    Have you overrided OnModelCreating or Initialize methods of your DbContext also? If so, call base methods as first line.

    That was it, thank you so much. Great support as always.

  • User Avatar
    0
    hikalkan created
    Support Team

    You're welcome :)