When call EntityType.FullName to identify object type at runtime the EntityType return DbContext namespace + Entity type name
anyone can help me if found any error in my code or if have solution to do this ...
anyone can help me if found any error in my code or if have solution to do this ...
namespace namespace1
{
public class MyObject{}
}
namespace namespace2
{
public class MyDbContext : DbContext
{
public DbSet<MyObject> MyObjectSet{ get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Configurations.Add<MyObject>(new MyObjectConfiguration());
base.OnModelCreating(modelBuilder);
}
}
}
public static void PrintEntitiesTypeName(DbContext dbContext)
{
ReadOnlyCollection<EntityType> AllTypes = ((IObjectContextAdapter)dbContext).ObjectContext.MetadataWorkspace.GetItems<EntityType>(DataSpace.CSpace);
foreach (EntityType item in AllTypes)
{
Console.WriteLine(item.FullName);
// Console Write
// __namespace2.MyObject instead namespace1.Myobject__
}
}