jeudi 21 janvier 2016

Entity Framework Model Builder Configuration using Reflection

I want to call the below code using reflection:

modelBuilder.Entity<CardPayment>().Map(m =>
            {
                m.MapInheritedProperties();
                m.ToTable("CardPayments");
            });

I am trying the following:

var entityMethod = typeof(DbModelBuilder).GetMethod("Entity");
entityMethod.MakeGenericMethod(type)
          .Invoke(modelBuilder, new object[] { });

How do I call the "Map" method with the parameters supplying the "Map" method. How can I invoke the "MapInheritedProperties" and "ToTable" methods within the "Map" method.

Thanks





Aucun commentaire:

Enregistrer un commentaire