Let’s walkthrough making a simple change to our Dinner
class. Specifically, we’ll add an additional property to our Dinner class
called “Country”:
Now that we’ve made this change, let’s press F5 in Visual
Studio to build and re-run the application. When we do this we’ll see the
below error message:
This error message occurs because we’ve changed the
structure of our Dinner class, and our model object is now no longer the same
shape as the “Dinners” table we automatically created within our
database.
When EF automatically creates a database for you, it by
default adds an “EdmMetadata” table to the database that tracks the shape of
the model objects that were used to automatically create the database schema
for you:
The error message above occurs when EF detects that you’ve
made a change to a model object and it is now out of sync with the database it
automatically created for you.