Skip to content
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

Update to EF8 #227

Merged
merged 2 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<EFCoreVersion>[7.0.2,8.0.0)</EFCoreVersion>
<MicrosoftExtensionsVersion>7.0.0</MicrosoftExtensionsVersion>
<EFCoreVersion>[8.0.0-rc.2.23480.1,9.0.0)</EFCoreVersion>
<MicrosoftExtensionsVersion>8.0.0-rc.2.23479.6</MicrosoftExtensionsVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
27 changes: 27 additions & 0 deletions EFCore.NamingConventions.Test/NameRewritingConventionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Waypoint>().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()
{
Expand Down Expand Up @@ -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; }
}
}
4 changes: 2 additions & 2 deletions EFCore.NamingConventions/EFCore.NamingConventions.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<VersionPrefix>7.0.2</VersionPrefix>
<TargetFramework>net8.0</TargetFramework>
<VersionPrefix>8.0.0</VersionPrefix>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../EFCore.NamingConventions.snk</AssemblyOriginatorKeyFile>
Expand Down
6 changes: 3 additions & 3 deletions EFCore.NamingConventions/Internal/NameRewritingConvention.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,14 @@ public void ProcessModelFinalizing(IConventionModelBuilder modelBuilder, IConven
private void RewriteColumnName(IConventionPropertyBuilder propertyBuilder)
{
var property = propertyBuilder.Metadata;
var entityType = property.DeclaringEntityType;
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(property.DeclaringEntityType, StoreObjectType.Table) is { } tableIdentifier
var baseColumnName = StoreObjectIdentifier.Create(structuralType, StoreObjectType.Table) is { } tableIdentifier
? property.GetDefaultColumnName(tableIdentifier)
: property.GetDefaultColumnName();
if (baseColumnName is not null)
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.100",
"version": "8.0.100-rc.2.23502.2",
"rollForward": "latestMajor",
"allowPrerelease": true
}
Expand Down