Is this metadata available in EF Core?
Yes it. Just study the methods in addition to the properties ( GetXXX , FindXXX , etc.). And pay particular attention to the extension methods of Relational() .
For instance:
foreach (var entityType in dbContext.Model.GetEntityTypes()) { var tableName = entityType.Relational().TableName; foreach (var propertyType in entityType.GetProperties()) { var columnName = propertyType.Relational().ColumnName; } }
You must have the Microsoft.EntityFrameworkCore.Relational Nuget package installed.
Update (EF Core 3. 0+): Relational() provider extensions were removed and the properties were replaced with direct Get / Set extension methods, so the code for the column / table names is now simple
var tableName = entityType.GetTableName();
source share