/// <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 ValidateOnlyETagConcurrencyToken( [NotNull] IModel model, [NotNull] IDiagnosticsLogger <DbLoggerCategory.Model.Validation> logger) { foreach (var entityType in model.GetEntityTypes()) { foreach (var property in entityType.GetDeclaredProperties()) { if (property.IsConcurrencyToken) { var storeName = property.GetJsonPropertyName(); if (storeName != "_etag") { throw new InvalidOperationException( CosmosStrings.NonETagConcurrencyToken(entityType.DisplayName(), storeName)); } var etagType = property.GetTypeMapping().Converter?.ProviderClrType ?? property.ClrType; if (etagType != typeof(string)) { throw new InvalidOperationException( CosmosStrings.ETagNonStringStoreType( property.Name, entityType.DisplayName(), etagType.ShortDisplayName())); } } } } }
public virtual void Detects_nonString_concurrency_token() { var modelBuilder = CreateConventionalModelBuilder(); modelBuilder.Entity <Customer>() .ToContainer("Orders") .Property <int>("_etag") .IsConcurrencyToken(); VerifyError(CosmosStrings.ETagNonStringStoreType("_etag", typeof(Customer).Name, "int"), modelBuilder); }