handle Entity Framework migration when live and development Database is same

asp.net-mvc c# entity-framework-6 entity-framework-migrations

Question

I am using entity framework 6 with code first approach. I use the same database for live & development purpose, when I make change in model or add new fields in the model, then add-migration and run update-database, migration add and update successfully locally and when run application from visual studio its works fine. But on the other hand my already published same application crashes, when I open the live URL, I see this error

enter image description here

one solution is to re-publish the application to live but I want a different best solution.

I want to know the best practice of working with entity framework , I can add or modify model using EF while live application working fine as it was working before model modification. I am using SQL Server as Database.

1
0
4/18/2020 9:33:17 AM

Popular Answer

I am use same database for live & development purpose,

This is so bad it is not even funny. THis means that you CAN NOT make breaking changes EVER. This also means that any error in code during development may destroy production data. This is like saying "I have health problems. I am swalling poison, why is it bad" bad.

Standard practice (not even best, it is STANDARD) is to have separate copies of the database for every environment. Many teams even make copies of the database for all or specific developers- even if the database is dozens of terabytes large.

But ONE database copy for development and production is NEVER going to work and it is obviously breaking the production database. Start using copies.

0
4/18/2020 8:34:33 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow