public virtual void Detects_property_and_embedded_type_mapped_to_same_property() { var modelBuilder = CreateConventionalModelBuilder(); modelBuilder.Entity <Order>( ob => { ob.Property(o => o.PartitionId).ToJsonProperty("Details"); ob.OwnsOne(o => o.OrderDetails).ToJsonProperty("Details"); }); VerifyError( CosmosStrings.JsonPropertyCollision( nameof(Order.OrderDetails), nameof(Order.PartitionId), typeof(Order).Name, "Details"), modelBuilder); }
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> protected virtual void ValidateDatabaseProperties( [NotNull] IModel model, [NotNull] IDiagnosticsLogger <DbLoggerCategory.Model.Validation> logger) { foreach (var entityType in model.GetEntityTypes()) { var properties = new Dictionary <string, IPropertyBase>(); foreach (var property in entityType.GetProperties()) { var jsonName = property.GetJsonPropertyName(); if (string.IsNullOrWhiteSpace(jsonName)) { continue; } if (properties.TryGetValue(jsonName, out var otherProperty)) { throw new InvalidOperationException( CosmosStrings.JsonPropertyCollision(property.Name, otherProperty.Name, entityType.DisplayName(), jsonName)); } properties[jsonName] = property; } foreach (var navigation in entityType.GetNavigations()) { if (!navigation.IsEmbedded()) { continue; } var jsonName = navigation.TargetEntityType.GetContainingPropertyName(); if (properties.TryGetValue(jsonName, out var otherProperty)) { throw new InvalidOperationException( CosmosStrings.JsonPropertyCollision(navigation.Name, otherProperty.Name, entityType.DisplayName(), jsonName)); } properties[jsonName] = navigation; } } }