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
FK without navigation properties #2517
Comments
It's ugly, but possible: modelBuilder.Entity<Post>(
x =>
{
x.Property<int>("BlogId");
x.References<Blog>().InverseCollection().ForeignKey("BlogId");
}); |
Thank you @bricelam, it's quite hard to figure it out :) but this is what I need! |
Discussed and decided that while the API isn't super awesome for this scenario, it is probably less common and we are ok with sticking with what we have for the moment. We could always add some sugar APIs later if we wanted to. |
Is this still valid as for the version |
RTM syntax: modelBuilder.Entity<Post>(
x =>
{
x.Property<int>("BlogId");
x.HasOne<Blog>().WithMany().HasForeignKey("BlogId");
}); |
@bricelam wonderful :) |
could i ask what is benefit of removing Navigation Property from Entity class? Can we use eager loading form then? |
Hi, I searched around the repo, but I didn't found nothing related, so if this is a dupe, feel free to close.
What I would like to have is the ability to define FK without navigation property, even better I would like to create a shadow state FK, to keep my class clean.
I would like to have this feature to implement e.g. a very simple auditing mechanism on each entity, to keep track of the last user that has updated a certain entity, but i would like to keep these fields off my entity.
Now I'm not able to create a FK without a navigation property, so IMHO this could be a quite useful feature.
Regards, Max
The text was updated successfully, but these errors were encountered: