-
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
Customize Navigation_ naming convention for Owned Type columns #17152
Comments
A better example is if I complete the modelBuilder.Entity<Order>().OwnsOne(
o => o.ShippingAddress,
sa =>
{
sa.Property(p => p.Street).HasColumnName("ShipsToStreet");
sa.Property(p => p.Street2).HasColumnName("ShipsToStreet2");
sa.Property(p => p.City).HasColumnName("ShipsToCity");
sa.Property(p => p.State).HasColumnName("ShipsToState");
sa.Property(p => p.Zip).HasColumnName("ShipsToZip");
sa.Property(p => p.Country).HasColumnName("ShipsToCountry");
}); vs modelBuilder.Entity<Order>().OwnsOne(
o => o.ShippingAddress,
prefix: "ShipsTo"); |
This is something that in the future could be a public convention. Backlogging for now. |
Great 👍 If you can point me in the right direction maybe I could implement it 😊? Where do I start looking in the code to add this? Seems pretty straight forward on the surface. |
@spottedmahn It is dependent on #214, which is a fairly substantial chunk of work and still requires some design. |
I see, thanks! I'll circle back once #214 is complete (only 3 checkboxes to go 😊) |
Related to #9329 |
#214 was closed 😊 |
On the nightly build or RC1 you can try adding your own convention. It would need to implement There isn't relevant documentation yet, see https://github.com/dotnet/efcore/blob/71b7f6dcc81a6285568305534ea7dd7e4edc7709/src/EFCore/Metadata/Conventions/KeyDiscoveryConvention.cs for an example |
@AndriySvyryd @ajcvickers Gentlemen this inability to set up an existing table to have an Owned Type property stops our porting away from EF6 to EF Core. We are heavy users of Complex Types, and in the EDMX model (which was amazing for the teams of all sizes by the way!) we were able to "map" a collection of existing columns "as they were" into a Complex Type. I understand that Owned Types have other useful functionality but there is something important that has been taken away! Please consider implementing a capability to allow for a custom prefix (or lack thereof!) Thank you! |
Same. My team have just hit the limits of owned type on Postgres due to limitations of column name sizes. We have so many nested properties that we are starting to get ambiguous column name errors because it cannot distinguish between different props of our types. |
I've just wasted hours on this problem. Wish I'd found this thread earlier. Can't believe this still isn't fixed, makes adding Owned types with a legacy database impossible. |
Describe what is not working as expected
I would like a way to customize the Navigation_ part of the convention in owned types:
Desired Behavior
In the above example, I want the
StreetAddress
properties to appear in the 'Orders' table as 'Street' and 'City'.ShipsTo Example
It would simplify the sample code to change
ShippingAddress_
toShipsTo
:vs
Thoughts? 💭
Further technical details
EF Core version: 2.1
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Win 10
IDE: 16.3 Preview 2
The text was updated successfully, but these errors were encountered: