Ignore DbSet property of DbContext base class RRS feed

  • Question

  • User44880335 posted


    I'm subclassing a DbContext whose base class has a DbSet<tentity> property.
    I want to configure my model to completely ignore that property, not generating a DB table for it at all. Is there a way to achieve that?

    Here's what I've tried:

    • Adding this to the OnModelBuilder of the sub class:
    • Shadowing the DbSet property with a new DbSet property of a different type (public new DbSet<tnewentity> { get; set; })
    Saturday, August 22, 2015 8:16 PM


  • User614698185 posted

    Hi Shimmy,

    According to your description, I think you want to ignore DbSet property of BdContext base class, and not generating a DB table for it at all. So, I think you could use Ignore method to accomplish it. I create the sample, code shown below:

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
      modelBuilder.Configurations.Add(new ShippingAddressMap());

    For more information, please refer to the following links:


    I hope this will help you.

    Best Regards,

    Candice Zhou

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 24, 2015 6:51 AM