-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow navigations and FK properties on non-collection complex types #31245
Comments
Adding needs-design as I believe we should allow (outgoing) navigations from complex types even when nested inside a collection. |
Hello team, I also need this feature. I am starting to adopt Complex Types in my domain, and I find it limiting not beeing able to have FKs inside of them. Here's a very simple example;
could become
But currently I get this error:
And so on and so on... This is a small example but you can see the potential benefits of it. This way I could enforce domain rules much more easyly. At the end of the day, it's just another column in the DataBase, so technicallities aside it would make sense to be able to do that, I think. Is there any work around you can think of? Is this planned for .NET 9? |
@vgallegob you should already be able to use owned entities to map the above; this issue is specifically about allowing navigations on complex types, which are a new mapping strategy (we don't yet know if we'll be able to deliver this for 9.0). If you're having trouble with owned entities, please open a new issue with a runnable, minimal code sample. |
I am already using Complex Types in my app. Would be nice to have it unified in Complex Types. For now I'll do this ones that have a FK with owned entities. Thanks Shay! |
This deserves more upvotes! |
@vgallegob Beautiful use case you have put forward! I just wanted to ask you why you said:
Your Value Object UserActivityCT will already be represented by two columns in your UserActivityEntity (one for At and one for ByUserId), so, I understand that what we want is to generate a FK from Created.ByUserId to User.Id. If I understand your case correctly, no new columns are needed. In fact, a syntax like the one that already exists would be great (but it doesn't work):
Finally, my analysis must also be applied to the Updated field. |
@CesarD Why do you need to map |
@AndriySvyryd because of the features ComplexTypes provide? Like being able to really use Records instead of mimicking them with classes and prevent having to track them as entities as it's the case of Owned Entities. |
Ok, then #11457 could be an alternative way of supporting your scenario. |
Not sure about that. I'm looking to have support more closely to Value Objects rather than yet another type of entity. |
All we want is a unified developer experience that allows mapping Value Objects in the DB. Navigation properties need to be represented in this unified way too, for convenience. |
The relationship itself will still be defined between two entity types.
Depends on #31236
The text was updated successfully, but these errors were encountered: