Closed bruno-garcia closed 1 year ago
You only need to give it the tablename:
foreach (var entity in modelBuilder.Model.GetEntityTypes())
{
var tableName = entity.GetEntityTableName();
foreach (var p in entity.FindPrimaryKey().Properties)
p.SetColumnName(p.GetColumnName(StoreObjectIdentifier.Table(tableName)).Replace("Dbo", "", StringComparison.InvariantCultureIgnoreCase));
}
@bruno-garcia Sorry, I didn't mean to imply by my answer that it was okay to keep calling the obsolete method. I meant it was okay to use the code contained in the implementation of the obsolete method. That is:
var columnName = property.GetColumnName(
StoreObjectIdentifier.Table(property.DeclaringEntityType.GetTableName(), null));
This is also described in the breaking changes documentation.
Oh, that helps a lot. Thanks @YeskaNova and @ajcvickers.
We (nuget-trends) were happily relying on this answer from @ajcvickers to keep the original code even after we bumped to .NET 5:
Now, we're targeting .NET 6 and the obsolete method is gone. It's unclear to me how I can use
StoreObjectIdentifier.Create
given the information I have in scope.The code we want to move to .NET 6 is here:
https://github.com/dotnet/nuget-trends/blob/b99c6d484db384049138b40bd9bc9f72fcc4db0d/src/NuGetTrends.Data/BasePostgresContext.cs#L64
Help appreciated as this is the only blocker we have to release NuGet Trends on .NET 6 RC2.