✅ Possible bug in EFCore nested complex properties as record type
Hi, I'm facing an issue while binding the following data models:
The error message I'm getting is the following (when running a migration):
I'm trying to update my system, maybe it is resolved with that new version.
15 Replies
It works (assuming I properly configure the required member to make the nullable complex types boundable) if I make the ScoreStatistics record a class with properties instead.
It feels like we can't bind a record as a complex type if it also contains other complex types.
But maybe my understanding is wrong, I also find the nullable complex type feature confusing. I expected a discriminator as a bool like "isNull" instead of relying on some properties. And even then, I don't know how to properly use the .HasDiscriminator() either.
It's fairly hard to have the expected behavior, sometimes, the properties don't even get mapped in the database, it just gets persisted as null.
Any pro here?
The issue is the same if I remove the nullability of ScoreStatistics btw. It doen't seem related to this.
if swapping
ScoreStatistics from a record to a class makes it all work, then that sure sounds like a bug to me
try swapping it to a class and also keeping all the constructor parameter names as PascalCase instead of camelCase
does it still fail?
I'm gonna make a guess that it will
indicating it's not an issue with records, per-se, it's that records decided it was a good idea to break the existing naming conventions that people (and libraries like EF) rely on. EF matches this for records normally, but perhaps they've missed a scenario that only occurs when using records as complex types, or only using them in a nested fashionUnknown User•4w ago
Message Not Public
Sign In & Join Server To View
complex types aren't entity types
I don't give a dam about tracking those either X)
i use a non tracking default
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
I know it works with a class
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
I don't want a class
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
GitHub
GuildSaber/src/GuildSaber.Database/Models/Server/Scores/BeatLeaderS...
Contribute to GuildSaber/GuildSaber development by creating an account on GitHub.
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
this works
I assume it's only when it's in a nested fashion. Because my other records as complex types just works. (on my other entities)
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
Yeah that's what I knew I had to do.
I didn't want to (laziness), that's why I came here first just in case X)
GitHub
Nested complex types can't be bound if the parent puts it in positi...
Bug description Given models that have nested complex types: Foo -> FooInfo -> Bar The positional parameters in primary constructor variant: record FooInfo(string Name, Bar Bar); fails the mi...