I have been following the ASP.Net Movie Database Tutorial, and it was all going well.
I have just changed the model and added an attribute. Call me curious, but I didn't want to follow the guide of just drop the database - I wanted to see if I can modify.
The correct error came up about a mismatch - which was expected.
I added the ratings column to the database, and everything worked.
Next, I deleted the ratings column as I wanted to follow the tutorial and learn about DropCreateDatabaseIfModelChanges
- however, I just get the error Invalid column name 'Ratings'.
In all this time, the ModelHash
entry has not changed, and I have no idea how it know there is a difference between now or before.
So - 1) Have I screwed something up?
2) How can I fix?
3) How did it know before that something has changed, but not now when the hash hasn't changed?
4) Is there any additional advice you can give?
I think you description must be incorrect because correct behavior will throw the exception despite of manually added Rating
column.
This behavior works as follows:
EdmMetadata
is added.EdmMetadata
contains two columns - Id
and ModelHash
. Adding manually Rating
column will not change stored hash but hash of the model will be different.
This behavior can be completely removed by removing IncludeMetadataConvention
convention:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Conventions.Remove(modelBuilder.Conventions
.OfType<IncludeMetadataConvention>().ToArray());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With