mardi 2 avril 2019

EntityType' is a variable but is used like a type when use the Reflection

i need to register all entity in DbContext .

i create a extention for register automatic all Entity with Reflection :

  public static void RegisterAllEntity<BaseType>(this DbModelBuilder builder, params Assembly[] assmblies)
    {
        IEnumerable<Type> types = assmblies.SelectMany(x => x.GetExportedTypes())
            .Where(x => x.IsClass && !x.IsAbstract && x.IsPublic && typeof(BaseType).IsAssignableFrom(x));

        foreach (Type EntityType in types)
            builder.Entity<EntityType>();
    }

but it show me this error :

EntityType' is a variable but is used like a type

in this line :

    foreach (Type EntityType in types)
            builder.Entity<EntityType>();

whats the problem ? how can i solve this problem ???





Aucun commentaire:

Enregistrer un commentaire