Is there a way to get table info defined with DbModelBuilder?
something like:
entity.GetType().GetTableName()
Max
EDIT:
Only solution i can imagine is reflection. Here it is
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
// model mappings
base.OnModelCreating(modelBuilder);
// table mapping
var config = modelBuilder.Configurations
.GetPrivateFieldValue("_modelConfiguration")
.GetPrivateFieldValue("ActiveEntityConfigurations");
var mapping = new Hashtable();
foreach (var c in (IEnumerable)config)
{
var type = (Type)c.GetPrivateFieldValue("ClrType");
var tableName = (string)c.GetPrivateFieldValue("EntitySetName");
mapping[type] = tableName;
}
// store mapping whereever needed
}
Main idea is to get configuration object after base.OnModelCreating has called.