//public static List<ORMMetadata> GetEntityMappingMetadta()
        //{
        //    SampleDBContext g = new SampleDBContext();

        //    Type type = typeof(SampleDBContext);

        //    var entityData = GetEntitywithProperties(type);

        //    return entityData;
        //}

        private static List <ORMMetadata> GetEntitywithProperties(Type type)
        {
            var contextruntimeproperties = type.GetRuntimeProperties();

            ORMMetadata        ormMetadataEntity = null;
            List <ORMMetadata> entityList        = new List <ORMMetadata>();

            foreach (var entity in contextruntimeproperties)
            {
                if (entity.PropertyType.Name == "DbSet`1")
                {
                    ormMetadataEntity = new ORMMetadata();

                    var entityProps = entity.PropertyType.GetGenericArguments();

                    ormMetadataEntity.EntiyFullName = entityProps[0].FullName;

                    ormMetadataEntity.EntityName = entityProps[0].Name;

                    foreach (var ep in entityProps)
                    {
                        var pi = ep.GetProperties();
                        foreach (var p in ep.GetProperties())
                        {
                            ormMetadataEntity.MemberOfClass.Add(new MemberOfClass {
                                PropertyName = p.Name
                            });
                        }
                    }
                    entityList.Add(ormMetadataEntity);
                }
            }
            return(entityList);
        }
        /// <summary>
        /// Get all Types from laoded Assembly
        /// </summary>
        /// <param name="typeInAssembly"></param>
        public static List <ORMMetadata> GetEntitiesFromAssembly()
        {
            var typeInAssembly = LoadAssembly();

            var ormList = new List <ORMMetadata>();

            var contextTypefromAssembly = typeInAssembly.Where(t => t.BaseType.FullName == "System.Data.Entity.DbContext").Select(e => e).ToList();

            foreach (Type t in contextTypefromAssembly)
            {
                Console.WriteLine(" Type is {0} drived from {1}", t, t.BaseType);

                Console.WriteLine("Get Properties info of drived class");

                var prop = t.GetProperties();

                var mm = t.GetMethods();

                var DbModel = prop.Where(f => f.PropertyType.Name == "DbSet`1").Select(p => p).ToList();

                foreach (var model in DbModel)
                {
                    var    typeInfo  = model.PropertyType.GetGenericArguments();
                    string assembly  = typeInfo[0].Assembly.GetName().Name;
                    string className = typeInfo[0].Name;

                    var propertyInfo = typeInfo[0].GetRuntimeProperties();

                    var orm = new ORMMetadata();
                    orm.AssemblyName  = assembly;
                    orm.EntityName    = className;
                    orm.EntiyFullName = typeInfo[0].FullName;
                    orm.Namespace     = typeInfo[0].Namespace;


                    foreach (var pi in propertyInfo)
                    {
                        var moc      = new MemberOfClass();
                        var propInfo = pi.Name;
                        moc.PropertyName = pi.Name;
                        orm.MemberOfClass.Add(moc);
                    }
                    ormList.Add(orm);
                }
            }

            return(ormList);
        }