Hi 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.
using (IEntityModelContext context = new EFDataContext()) {
var licTypeFact = context.GetFactory<LicenceType>();
var metaValFact = context.GetFactory<MetaValue>();
var cultSpecFact = context.GetFactory<CultureSpecificValue>();
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 => cult.Name == "Eng");
licNameEng.MetaValue = licTypeName;
licTypeName.CultureSpecificValues = new List<CultureSpecificValue>();
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();
So what can be the reason of this exception?