Note that there are some explanatory texts on larger screens.

plurals
  1. POEF 4.0 UpdateException
    primarykey
    data
    text
    <p>I'm using EF 4.0 within VS 2010 RC. I have pretty simple POCO class structure with few dependencies. Each POCO class has a base generic class (EntityObject or ValueObect) with property ID. I have several CRUD tests and only one of them works. This one is very simple where object does not have any dependencies. But when I test something with FK dependencies I always get the same error: System.Data.UpdateException: A value shared across entities or associations is generated in more than one location. Check that mapping does not split an EntityKey to multiple store-generated columns. I've googled that but the only reason of this exception that I found is usage of several contextes which is not my case. </p> <pre><code> using (IEntityModelContext context = new EFDataContext()) { var licTypeFact = context.GetFactory&lt;LicenceType&gt;(); var metaValFact = context.GetFactory&lt;MetaValue&gt;(); var cultSpecFact = context.GetFactory&lt;CultureSpecificValue&gt;(); LicenceType licType = licTypeFact.CreateObject(); Assert.IsNotNull(licType); Assert.IsTrue(licType.IsTransient); licType.AdvancedFeatureSet = true; licType.BasicFeatureSet = true; licType.MaxUsers = 10; licType.MonthDuration = 1; MetaValue licTypeName = metaValFact.CreateObject(); licTypeName.Name = "TestLicType"; CultureSpecificValue licNameEng = cultSpecFact.CreateObject(); licNameEng.Value = "Test Licence"; licNameEng.Culture = context.CultureRepository.Load(cult =&gt; cult.Name == "Eng"); licNameEng.MetaValue = licTypeName; licTypeName.CultureSpecificValues = new List&lt;CultureSpecificValue&gt;(); licTypeName.CultureSpecificValues.Add(licNameEng); licType.Name = licTypeName; licType.NumberOfQuestionsPerSurvey = 1; licType.NumberOfResponsesPerSurvey = 2; licType.NumberOfSurveys = 3; licType.PerUserPrice = 10; licType.Price = 100; context.LicenceTypeRepository.Add(licType); int res = context.SaveChanges(); </code></pre> <p>So what can be the reason of this exception?</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.
 

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