public virtual InternalEntityEntry PrepareToSave()
        {
            if (EntityState == EntityState.Added)
            {
                var setProperty = EntityType.GetProperties().FirstOrDefault(p => p.IsReadOnlyBeforeSave && !IsTemporaryOrSentinel(p));
                if (setProperty != null)
                {
                    throw new InvalidOperationException(Strings.PropertyReadOnlyBeforeSave(setProperty.Name, EntityType.DisplayName()));
                }
            }
            else if (EntityState == EntityState.Modified)
            {
                var modifiedProperty = EntityType.GetProperties().FirstOrDefault(p => p.IsReadOnlyAfterSave && IsPropertyModified(p));
                if (modifiedProperty != null)
                {
                    throw new InvalidOperationException(Strings.PropertyReadOnlyAfterSave(modifiedProperty.Name, EntityType.DisplayName()));
                }
            }

            var properties = MayGetStoreValue();

            if (properties.Any())
            {
                AddSidecar(MetadataServices.CreateStoreGeneratedValues(this, properties));
            }

            return(this);
        }
        public virtual InternalEntityEntry PrepareToSave()
        {
            var properties = MayGetStoreValue();

            if (properties.Any())
            {
                AddSidecar(MetadataServices.CreateStoreGeneratedValues(this, properties));
            }

            return(this);
        }