2

I have the following entity class:

[System.ComponentModel.DataAnnotations.Schema.Table("User")]
public class User: UserBase, IPersistCustom<Entity> { ... }

Depending on the type of hierarchy mapping you use, EF will generate either a descriptor column or split tables. Is there a way to have EF completely ignore the fact that this class inherits from something or implements an interface?

I don't mean just ignoring base class properties.

2
  • what do mean by ignore... what should happen ? Commented Feb 1, 2013 at 15:50
  • If you don't want or can't make base class abstract there is a better option Commented Aug 18, 2017 at 17:52

2 Answers 2

1

If you mark your base class(es) as abstract and use table per concrete type approach this may work. Something like;

context.Entity<User>().Map(p =>
        {
            p.MapInheritedProperties();
            p.ToTable("Users");
        });           

refer to this.

Sign up to request clarification or add additional context in comments.

Comments

0

are you looking for this.... fluent API option

 modelBuilder.Entity<XYZ>().Ignore(p => p.PropertyName);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.