Polymorphic Code-First Models and Querying
up vote
0
down vote
favorite
I'm trying to build a survey system and want to use inheritance on the Question
model, using code-first migrations.
public class MultipleChoiceQuestion : Question {
public bool AllowMultipleSelection { get; set; }
public List<MCQOption> Options { get; set; }
}
Even if I add another DbSet<MultipleChoiceQuestion>
, it doesn't appear in the migrations. What am I doing wrong?
c# inheritance ef-code-first ef-core-2.1
add a comment |
up vote
0
down vote
favorite
I'm trying to build a survey system and want to use inheritance on the Question
model, using code-first migrations.
public class MultipleChoiceQuestion : Question {
public bool AllowMultipleSelection { get; set; }
public List<MCQOption> Options { get; set; }
}
Even if I add another DbSet<MultipleChoiceQuestion>
, it doesn't appear in the migrations. What am I doing wrong?
c# inheritance ef-code-first ef-core-2.1
It doesn't add anything that would result in additional columns, so another table isn't needed (presumably theMCQOption
has a FK back toQuestion
)
– juharr
yesterday
@juharr guess I oversimplified my sample code. Fixed it to solve the case you mentioned.
– Ali Almohsen
yesterday
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm trying to build a survey system and want to use inheritance on the Question
model, using code-first migrations.
public class MultipleChoiceQuestion : Question {
public bool AllowMultipleSelection { get; set; }
public List<MCQOption> Options { get; set; }
}
Even if I add another DbSet<MultipleChoiceQuestion>
, it doesn't appear in the migrations. What am I doing wrong?
c# inheritance ef-code-first ef-core-2.1
I'm trying to build a survey system and want to use inheritance on the Question
model, using code-first migrations.
public class MultipleChoiceQuestion : Question {
public bool AllowMultipleSelection { get; set; }
public List<MCQOption> Options { get; set; }
}
Even if I add another DbSet<MultipleChoiceQuestion>
, it doesn't appear in the migrations. What am I doing wrong?
c# inheritance ef-code-first ef-core-2.1
c# inheritance ef-code-first ef-core-2.1
edited yesterday
asked yesterday
Ali Almohsen
5842717
5842717
It doesn't add anything that would result in additional columns, so another table isn't needed (presumably theMCQOption
has a FK back toQuestion
)
– juharr
yesterday
@juharr guess I oversimplified my sample code. Fixed it to solve the case you mentioned.
– Ali Almohsen
yesterday
add a comment |
It doesn't add anything that would result in additional columns, so another table isn't needed (presumably theMCQOption
has a FK back toQuestion
)
– juharr
yesterday
@juharr guess I oversimplified my sample code. Fixed it to solve the case you mentioned.
– Ali Almohsen
yesterday
It doesn't add anything that would result in additional columns, so another table isn't needed (presumably the
MCQOption
has a FK back to Question
)– juharr
yesterday
It doesn't add anything that would result in additional columns, so another table isn't needed (presumably the
MCQOption
has a FK back to Question
)– juharr
yesterday
@juharr guess I oversimplified my sample code. Fixed it to solve the case you mentioned.
– Ali Almohsen
yesterday
@juharr guess I oversimplified my sample code. Fixed it to solve the case you mentioned.
– Ali Almohsen
yesterday
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53398478%2fpolymorphic-code-first-models-and-querying%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It doesn't add anything that would result in additional columns, so another table isn't needed (presumably the
MCQOption
has a FK back toQuestion
)– juharr
yesterday
@juharr guess I oversimplified my sample code. Fixed it to solve the case you mentioned.
– Ali Almohsen
yesterday