Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

New Post: EntityType [FullName] Property Return Unexpected Result In EF5.x & EF6.x

$
0
0
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 ...
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__
            }
        }

Viewing all articles
Browse latest Browse all 10318

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>