NRE when adding property named "Count" to a property bag entity type #25485
Labels
area-model-building
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
type-bug
Milestone
Originally filed at PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#1491
This seems to be a bug in EF Core that is only triggered for specific entity property names (e.g. when your property is named
Count
) in migration snapshots.The underlying issue seems to be, that EF Core is checking the properties of the wrong type. It does enumerated the properties of the
Metadata.ClrType
property, but it is not set to the actual entity type (since this is a migration snapshot), but to a type ofDictionary<string, object>
.It then hits the
Count
property of thisDictionary<string, object>
, checks itsint
type against the expecteddouble
type of the entity's property, realizes that they do not match, and finally returns null, which will then throws the NRE.This is the line with the issue:
efcore/src/EFCore/Metadata/Internal/InternalEntityTypeBuilder.cs
Line 579 in 159c7e7
@AndriySvyryd, @ajcvickers Reproduced with the following code:
Program.cs
Add an initial migration and then another one (can be empty).
Should be reproducible with any provider.
The text was updated successfully, but these errors were encountered: