juliandormon
asked on
MVC Code-First migration scaffold self-referential model
I have a constructed a model using code first in C#. The model literally represents a container element for a website building application, in other words, the model defines a Div tag or some such HTML element. Like a Div tag which can contain multiple child elements, I have tried to represent this in my model, but the scaffolding to the DB, does not give me what I'd expect.
I should get a new many to many joins table, but instead I only get a single column in the DB which expects a single int data type.
Here is the model:
The last line is the self-referential attribute which just appears as a column called ElementContainer_ElementCo ntainerID
Thanks in advance!
I should get a new many to many joins table, but instead I only get a single column in the DB which expects a single int data type.
Here is the model:
public class ElementContainer
{
public int ElementContainerID { get; set; }
public int PageId { get; set; }
public int? ParentElementContainerID { get; set; }
public string ElementContainerName { get; set; }
public ElementType ElementType { get; set; }
public string ElementClass { get; set; }
public List<ElementContainer> NestedContainers { get; set; }
}
The last line is the self-referential attribute which just appears as a column called ElementContainer_ElementCo
Thanks in advance!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I've requested that this question be closed as follows:
Accepted answer: 0 points for juliandormon's comment #a38827034
for the following reason:
Good straight forward answer.
Accepted answer: 0 points for juliandormon's comment #a38827034
for the following reason:
Good straight forward answer.
I'm assuming the poster meant my answer was a "Good straight forward answer" so I'm not sure why there is a close request pending. I feel I should get the points for answering the question correctly.
ASKER