private void PropagateConceptualSGPToStorageProperty(StorageProperty sProp) { if (null == sProp) { Debug.Fail("null StorageProperty"); return; } if (sProp.IsDisposed) { // this StorageProperty was deleted after this integrity check was created but // before it was invoked - not an error - just ignore this property return; } if (sProp.IsKeyProperty) { if (IsStorageForNonRootEntityType(sProp)) { // this StorageProperty is for a key column on a table which acts as storage for a non-root EntityType // (e.g. in a TPT hierarchy). So do not set SGP - it should be set only on the root column. return; } if (IsDependentSidePropertyInAssociation(sProp)) { // this StorageProperty is used in the dependent side of an Association. // So do not set SGP - it should be set only on the principal side. return; } } // loop over ConceptualProperties mapped to this StorageProperty foreach (var sp in sProp.GetAntiDependenciesOfType <ScalarProperty>()) { // only use ScalarProperty elements inside an EntitySetMapping or EntityTypeMapping // (MappingFragment is only used by those types of mappings) if (null != sp.GetParentOfType(typeof(MappingFragment))) { // only propagate values from non-key C-side properties var cProp = sp.Name.Target as ConceptualProperty; if (cProp != null) { var cSideSGPValue = cProp.StoreGeneratedPattern.Value; if (_propagateNoneSGP || false == ModelConstants.StoreGeneratedPattern_None.Equals(cSideSGPValue, StringComparison.Ordinal)) { // have found a C-side property whose SGP value should be propagated if (false == cSideSGPValue.Equals(sProp.StoreGeneratedPattern.Value, StringComparison.Ordinal)) { var cmd = new UpdateDefaultableValueCommand <string>(sProp.StoreGeneratedPattern, cSideSGPValue); CommandProcessor.InvokeSingleCommand(_cpc, cmd); } return; } // Otherwise have found a C-side SGP but it has value "None" and have been told not to propagate "None" values // (will apply to where SGP is absent too since "None" is the default value). // So loop round looking for the next C-side SGP to see if it applies. } } } }