diff --git a/Directory.Packages.props b/Directory.Packages.props index db7cb1d..d13cfa8 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,7 +1,7 @@ - [7.0.2,8.0.0) - 7.0.0 + [8.0.0-rc.2.23480.1,9.0.0) + 8.0.0-rc.2.23479.6 diff --git a/EFCore.NamingConventions.Test/EFCore.NamingConventions.Test.csproj b/EFCore.NamingConventions.Test/EFCore.NamingConventions.Test.csproj index a5f2179..53bd83d 100644 --- a/EFCore.NamingConventions.Test/EFCore.NamingConventions.Test.csproj +++ b/EFCore.NamingConventions.Test/EFCore.NamingConventions.Test.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 diff --git a/EFCore.NamingConventions.Test/NameRewritingConventionTest.cs b/EFCore.NamingConventions.Test/NameRewritingConventionTest.cs index 4b58693..72498ef 100644 --- a/EFCore.NamingConventions.Test/NameRewritingConventionTest.cs +++ b/EFCore.NamingConventions.Test/NameRewritingConventionTest.cs @@ -531,6 +531,21 @@ public void Owned_entity_withs_OwnsMany() .GetColumnName(StoreObjectIdentifier.Create(ownedEntityType, StoreObjectType.Table)!.Value)); } + [Fact] + public void Complex_property() + { + var model = BuildModel(b => + b.Entity().ComplexProperty(w => w.Location)); + + var entityType = model.FindEntityType(typeof(Waypoint))!; + var complexType = entityType.FindComplexProperty("Location")!.ComplexType; + + Assert.Equal("location_longitude", complexType.FindProperty("Longitude")! + .GetColumnName(StoreObjectIdentifier.Create(entityType, StoreObjectType.Table)!.Value)); + Assert.Equal("location_latitude", complexType.FindProperty("Latitude")! + .GetColumnName(StoreObjectIdentifier.Create(entityType, StoreObjectType.Table)!.Value)); + } + [Fact] public void Not_mapped_to_table() { @@ -658,4 +673,16 @@ public class Owned { public int OwnedProperty { get; set; } } + + public class Waypoint + { + public int Id { get; set; } + public required Location Location { get; set; } + } + + public class Location + { + public double Longitude { get; set; } + public double Latitude { get; set; } + } } diff --git a/EFCore.NamingConventions/EFCore.NamingConventions.csproj b/EFCore.NamingConventions/EFCore.NamingConventions.csproj index 3279ddf..45583ea 100644 --- a/EFCore.NamingConventions/EFCore.NamingConventions.csproj +++ b/EFCore.NamingConventions/EFCore.NamingConventions.csproj @@ -1,8 +1,8 @@ - net6.0 - 7.0.2 + net8.0 + 8.0.0 true true ../EFCore.NamingConventions.snk diff --git a/EFCore.NamingConventions/Internal/NameRewritingConvention.cs b/EFCore.NamingConventions/Internal/NameRewritingConvention.cs index 361a175..d6cbb1c 100644 --- a/EFCore.NamingConventions/Internal/NameRewritingConvention.cs +++ b/EFCore.NamingConventions/Internal/NameRewritingConvention.cs @@ -293,14 +293,14 @@ public void ProcessModelFinalizing(IConventionModelBuilder modelBuilder, IConven private void RewriteColumnName(IConventionPropertyBuilder propertyBuilder) { var property = propertyBuilder.Metadata; - var entityType = (IConventionEntityType)property.DeclaringType; + var structuralType = property.DeclaringType; // Remove any previous setting of the column name we may have done, so we can get the default recalculated below. property.Builder.HasNoAnnotation(RelationalAnnotationNames.ColumnName); // TODO: The following is a temporary hack. We should probably just always set the relational override below, // but https://github.com/dotnet/efcore/pull/23834 - var baseColumnName = StoreObjectIdentifier.Create(entityType, StoreObjectType.Table) is { } tableIdentifier + var baseColumnName = StoreObjectIdentifier.Create(structuralType, StoreObjectType.Table) is { } tableIdentifier ? property.GetDefaultColumnName(tableIdentifier) : property.GetDefaultColumnName(); if (baseColumnName is not null) @@ -310,7 +310,7 @@ private void RewriteColumnName(IConventionPropertyBuilder propertyBuilder) foreach (var storeObjectType in _storeObjectTypes) { - var identifier = StoreObjectIdentifier.Create(entityType, storeObjectType); + var identifier = StoreObjectIdentifier.Create(structuralType, storeObjectType); if (identifier is null) { continue; diff --git a/global.json b/global.json index 7f2000d..a8f2e26 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.100", + "version": "8.0.100-rc.2.23502.2", "rollForward": "latestMajor", "allowPrerelease": true }