0

I created an application in Asp.Net MVC using the database first method. I generated my model using an edmx file. However i made a change to my context classes. Everytime i run my

application i get the following error:

"The model backing the 'ArticleContext' context has changed since the database was created. Consider using Code First Migrations to update the database"

Should i follow the advice the error gives me? Even though i used the "database first" method?

user1574041
  • 247
  • 4
  • 16
  • It appears to me that you are not using model first otherwise EF would not be able to tell whether the model changed or not. You might have started database first but it looks that for some reason EF then created a database it's using. Show some code otherwise it is hard to tell what's happening. – Pawel Jan 13 '13 at 00:42

1 Answers1

1

That depends. Database first approach doesn't only mean that you had the database first and you decide to create your model after that. It also means (in most cases) that database structure would really decide on how your model classes look like. Safest approach is to makde changes on the DB side and promoting them to your model by simply refreshing code from EDMX. If you really need to make some changes to the model classes, do it by implementing parital classes or ViewModels.

Paweł Staniec
  • 3,151
  • 3
  • 29
  • 41