Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>However the initial problem has gone after recreation of edmx, yet another one arised. I have class which definition looks like this:</p> <pre><code> public class ValueList: EntityObject&lt;Int32&gt; { public virtual MetaValue Name { get; set; } public virtual IList&lt;MetaValue&gt; Values { get; set; } } </code></pre> <p>And here is MetaValue class definition:</p> <pre><code> public class MetaValue : EntityObject&lt;Int32&gt; { public string Name { get; set; } public virtual IList&lt;CultureSpecificValue&gt; CultureSpecificValues { get; set; } } </code></pre> <p>Values property in ValueList represents Many-To-many relationship between ValueLists and MetaValues tables (joining table ValueListMetaValues with two FK columns and PK on both). The CRUD test for this item looks like this:</p> <pre><code> using (IEntityModelContext context = new EFDataContext()) { var valueListFact = context.GetFactory&lt;ValueList&gt;(); ValueList newValList = valueListFact.CreateObject(); Assert.IsNotNull(newValList); Assert.IsTrue(newValList.IsTransient); var metaValFact = context.GetFactory&lt;MetaValue&gt;(); var cultSpecFact = context.GetFactory&lt;CultureSpecificValue&gt;(); MetaValue listName = metaValFact.CreateObject(); MetaValue valOne = metaValFact.CreateObject(); MetaValue valTwo = metaValFact.CreateObject(); listName.Name = "list"; valOne.Name = "One"; valTwo.Name = "Two"; newValList.Name = listName; newValList.Values = new List&lt;MetaValue&gt;() { valOne, valTwo }; context.ValueListRepository.Add(newValList); context.SaveChanges(); </code></pre> <p>So after context.SaveChanges() listName is saved and valOne and valTwo are not. Moreover, after detaching and retreiving this object from DB its Values propety is filled with one value - listName and the Name also (the same object in Name and Values propeties). So is the problem again in edmx, or such structure (with FK and manyTomany in the same entity) is somehow misinterpreted by EF?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload