1
Class GeneralRequest 
{    
String BaseProperty { get set}
}

RapidRequest: GeneralRequest
{
Bool IsSignRequired { get set}    
}

BackRequest : GeneralRequest
{
Bool IsSignRequired { get set}    
}

OtherRequest: GeneralRequest
{   
String Note   { get set}   
}

This is the structure of codes I have in my project.

The property IsSignRequired comes in BackRequest and RapidRequest but it need not come in OtherRequest.

But when I generate database using this codes.

I get property IsSignRequired comes twice in my table as IsSignRequired1 IsSignRequired2 etc.

How can I specify that it is only neded once in my table

4
  • 1
    What is your mapping configuration? Commented May 13, 2015 at 11:24
  • Where is the OtherRequest property in your model? I see the OtherRequest class only. Commented May 13, 2015 at 15:01
  • it is IsSignRequired proprty.Let me edit the post thanks roman Commented May 14, 2015 at 13:30
  • Thanks roman for pointing the mistake Commented May 14, 2015 at 14:06

1 Answer 1

1

You either need to have another intermediate class that RapidRequest and BackRequest inherits from that defines an inherited IsSignRequired, or use the ColumnAttribute to force the name of the field. Another option is to use TablePerType inheritance, but that will generate separate tables for unique fields for each subclass.

EntityFramework is doing this because the field is declared independently on the subclasses. By default each subclass will get unique copies of any fields defined in that class, only inherited fields will be shared.

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

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.