mercredi 6 avril 2016

Emit entity framework DbContext class

How can I generate this class using dynamic builder

 public partial class testContext : DbContext
{
    static testContext()
    {
        Database.SetInitializer<testContext>(null);
    }

    public testContext()
        : base("Name=testContext")
    {
    }


    public DbSet<City> Cities { get; set; }


    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Configurations.Add(new CityMap());
    }
}

I have generated some parts but I don't know how to do it for the "OnModelCreating" method.





Aucun commentaire:

Enregistrer un commentaire