Utsuhoagie
Explore posts from serversEF Core with TPC hierarchy: InvalidCastException despite no casting
I have a problem when trying to use TPC hierarchy mapping in EF Core 8, where I get
InvalidCastException
s despite never casting anything.
What I wanted to do is have a BaseAuditedEntity
class for most models in my app, so that I could use it for a feature: TierList
entity has many TierListItem
s, and each TierListItem
relates to a BaseAuditedEntity
entity in the app, such as a Circle
(music group) or ArrangementSong
or any other base entity.
The (simplified) models:
The base classes configuration:
A simple query could be like this:
But when running, I get this exception (it doesn't happen if I don't .Include(a => a.Circle)
) in the logs.
I'm guessing that this is a problem with BaseEntity
rows in the DB. There is no BaseEntity
table because it's TPC, but after a migration I made to update the models from standalone Id
s to using a base class, then I see that they use a common sequence. However, the existing Id
s are unchanged, so there are many rows that share the same Id
s. But I'm not sure if this is actually the cause, or how to fix this.
Any help is greatly appreciated!12 replies
❔ Why is my ASP.NET Core Web API not responding at all to a `multipart/form-data` request?
Specifically my client is Expo Go (React Native) on a physical Android, and the request does work in Postman.
On my server:
On my client, I'm creating a request like this:
But whenever I try to send this request, the server does not respond at all. However, if I remove the headers (default
Content-Type: application/json
) then it does respond with 400
, along with these logs:
5 replies