0

I wrote a small WPF app using EF without enabling migrations a while ago and deployed. I have continued to work on my application and have realised that my current version is going to fail when I redeploy because I have not got upgrade scripts.

Does my idea below sound like it could work?

Create a new project and use EF, enabling migrations. Create new model project and DAL. Create model by pointing to existing deployed DB and set as initial migration. Enable migrations on my existing project and paste my migrations folder into existing project then add migration.

My thinking is that I will get initial DB matching existing deployed schema then when I add migration it will check against initial and create me the up/down for when I next deploy.

Any advice appreciated.

1

1 Answer 1

0

My deployment had had migrations enabled (I found out after taking backup, don't remember running that but must've because I have a _migrationHistory table!!!!), unfortunately, and amateurishly, I had deleted the migrations folder from my dev code and not checked into source control prior to doing so.... So I:

  1. Backed up client database
  2. Restored the backup from step 1 on my local SQLExpress
  3. Pointed my application connection string at newly restored DB
  4. Opened package manager console
  5. Selected my DAL project as default project
  6. Ran "enable-migrations"

This straight away picked up my previous, initial creation from database. This takes me back to before I messed around and deleted migrations folder from project!!!

Thank you MS boys & girls.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.