diff --git a/src/EFCore.Abstractions/EFCore.Abstractions.baseline.json b/src/EFCore.Abstractions/EFCore.Abstractions.baseline.json index 3401f9f7a8e..bdb33688107 100644 --- a/src/EFCore.Abstractions/EFCore.Abstractions.baseline.json +++ b/src/EFCore.Abstractions/EFCore.Abstractions.baseline.json @@ -177,10 +177,6 @@ "Methods": [ { "Member": "IndexAttribute(string propertyName, params string[] additionalPropertyNames);" - }, - { - "Member": "IndexAttribute(params string[] propertyNames);", - "Stage": "Obsolete" } ], "Properties": [ diff --git a/src/EFCore.Abstractions/IndexAttribute.cs b/src/EFCore.Abstractions/IndexAttribute.cs index d603fa436ff..113d2210da4 100644 --- a/src/EFCore.Abstractions/IndexAttribute.cs +++ b/src/EFCore.Abstractions/IndexAttribute.cs @@ -34,19 +34,6 @@ public IndexAttribute(string propertyName, params string[] additionalPropertyNam ((List)PropertyNames).AddRange(additionalPropertyNames); } - /// - /// Initializes a new instance of the class. - /// - /// The properties which constitute the index, in order (there must be at least one). - [Obsolete("Use the other constructor")] - public IndexAttribute(params string[] propertyNames) - { - Check.NotEmpty(propertyNames); - Check.HasNoEmptyElements(propertyNames); - - PropertyNames = propertyNames.ToList(); - } - /// /// The properties which constitute the index, in order. /// diff --git a/src/EFCore.Cosmos/Diagnostics/CosmosEventId.cs b/src/EFCore.Cosmos/Diagnostics/CosmosEventId.cs index 19f7fac4f10..8027da060bd 100644 --- a/src/EFCore.Cosmos/Diagnostics/CosmosEventId.cs +++ b/src/EFCore.Cosmos/Diagnostics/CosmosEventId.cs @@ -30,17 +30,17 @@ private enum Id // Command events ExecutingSqlQuery = CoreEventId.ProviderBaseId + 100, - ExecutingReadItem, - ExecutedReadNext, - ExecutedReadItem, - ExecutedCreateItem, - ExecutedReplaceItem, - ExecutedDeleteItem, - ExecutedTransactionalBatch, + ExecutingReadItem = CoreEventId.ProviderBaseId + 101, + ExecutedReadNext = CoreEventId.ProviderBaseId + 102, + ExecutedReadItem = CoreEventId.ProviderBaseId + 103, + ExecutedCreateItem = CoreEventId.ProviderBaseId + 104, + ExecutedReplaceItem = CoreEventId.ProviderBaseId + 105, + ExecutedDeleteItem = CoreEventId.ProviderBaseId + 106, + ExecutedTransactionalBatch = CoreEventId.ProviderBaseId + 107, // Update events PrimaryKeyValueNotSet = CoreEventId.ProviderBaseId + 200, - BulkExecutionWithTransactionalBatch, + BulkExecutionWithTransactionalBatch = CoreEventId.ProviderBaseId + 201, // Model validation events NoPartitionKeyDefined = CoreEventId.ProviderBaseId + 600, diff --git a/src/EFCore.Cosmos/EFCore.Cosmos.baseline.json b/src/EFCore.Cosmos/EFCore.Cosmos.baseline.json index 587881e0f81..2b0a6fa9d0d 100644 --- a/src/EFCore.Cosmos/EFCore.Cosmos.baseline.json +++ b/src/EFCore.Cosmos/EFCore.Cosmos.baseline.json @@ -317,10 +317,6 @@ { "Member": "static bool CanSetJsonProperty(this Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionEntityTypeBuilder entityTypeBuilder, string? name, bool fromDataAnnotation = false);" }, - { - "Member": "static bool CanSetPartitionKey(this Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionEntityTypeBuilder entityTypeBuilder, string? name, bool fromDataAnnotation = false);", - "Stage": "Obsolete" - }, { "Member": "static bool CanSetPartitionKey(this Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionEntityTypeBuilder entityTypeBuilder, System.Collections.Generic.IReadOnlyList? names, bool fromDataAnnotation = false);" }, @@ -381,10 +377,6 @@ { "Member": "static Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder HasPartitionKey(this Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder entityTypeBuilder, System.Linq.Expressions.Expression> propertyExpression);" }, - { - "Member": "static Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionEntityTypeBuilder? HasPartitionKey(this Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionEntityTypeBuilder entityTypeBuilder, string? name, bool fromDataAnnotation = false);", - "Stage": "Obsolete" - }, { "Member": "static Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionEntityTypeBuilder? HasPartitionKey(this Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionEntityTypeBuilder entityTypeBuilder, System.Collections.Generic.IReadOnlyList? propertyNames, bool fromDataAnnotation = false);" }, @@ -510,30 +502,6 @@ { "Member": "static System.Collections.Generic.IReadOnlyList GetPartitionKeyProperties(this Microsoft.EntityFrameworkCore.Metadata.IEntityType entityType);" }, - { - "Member": "static Microsoft.EntityFrameworkCore.Metadata.IReadOnlyProperty? GetPartitionKeyProperty(this Microsoft.EntityFrameworkCore.Metadata.IReadOnlyEntityType entityType);", - "Stage": "Obsolete" - }, - { - "Member": "static Microsoft.EntityFrameworkCore.Metadata.IMutableProperty? GetPartitionKeyProperty(this Microsoft.EntityFrameworkCore.Metadata.IMutableEntityType entityType);", - "Stage": "Obsolete" - }, - { - "Member": "static Microsoft.EntityFrameworkCore.Metadata.IConventionProperty? GetPartitionKeyProperty(this Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType entityType);", - "Stage": "Obsolete" - }, - { - "Member": "static Microsoft.EntityFrameworkCore.Metadata.IProperty? GetPartitionKeyProperty(this Microsoft.EntityFrameworkCore.Metadata.IEntityType entityType);", - "Stage": "Obsolete" - }, - { - "Member": "static string? GetPartitionKeyPropertyName(this Microsoft.EntityFrameworkCore.Metadata.IReadOnlyEntityType entityType);", - "Stage": "Obsolete" - }, - { - "Member": "static Microsoft.EntityFrameworkCore.Metadata.ConfigurationSource? GetPartitionKeyPropertyNameConfigurationSource(this Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType entityType);", - "Stage": "Obsolete" - }, { "Member": "static System.Collections.Generic.IReadOnlyList GetPartitionKeyPropertyNames(this Microsoft.EntityFrameworkCore.Metadata.IReadOnlyEntityType entityType);" }, @@ -588,14 +556,6 @@ { "Member": "static bool? SetHasShadowId(this Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType entityType, bool? alwaysCreate, bool fromDataAnnotation = false);" }, - { - "Member": "static void SetPartitionKeyPropertyName(this Microsoft.EntityFrameworkCore.Metadata.IMutableEntityType entityType, string? name);", - "Stage": "Obsolete" - }, - { - "Member": "static string? SetPartitionKeyPropertyName(this Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType entityType, string? name, bool fromDataAnnotation = false);", - "Stage": "Obsolete" - }, { "Member": "static void SetPartitionKeyPropertyNames(this Microsoft.EntityFrameworkCore.Metadata.IMutableEntityType entityType, System.Collections.Generic.IReadOnlyList? names);" }, diff --git a/src/EFCore.Cosmos/Extensions/CosmosEntityTypeBuilderExtensions.cs b/src/EFCore.Cosmos/Extensions/CosmosEntityTypeBuilderExtensions.cs index 80d0452bc1a..84336f2e3f7 100644 --- a/src/EFCore.Cosmos/Extensions/CosmosEntityTypeBuilderExtensions.cs +++ b/src/EFCore.Cosmos/Extensions/CosmosEntityTypeBuilderExtensions.cs @@ -273,46 +273,6 @@ public static EntityTypeBuilder HasPartitionKey( return entityTypeBuilder; } - /// - /// Configures the property that is used to store the partition key. - /// - /// - /// See Modeling entity types and relationships, and - /// Accessing Azure Cosmos DB with EF Core for more information and examples. - /// - /// The builder for the entity type being configured. - /// The name of the partition key property. - /// Indicates whether the configuration was specified using a data annotation. - /// - /// The same builder instance if the configuration was applied, - /// otherwise. - /// - [Obsolete("Use HasPartitionKey(IReadOnlyList, bool)")] - public static IConventionEntityTypeBuilder? HasPartitionKey( - this IConventionEntityTypeBuilder entityTypeBuilder, - string? name, - bool fromDataAnnotation = false) - => entityTypeBuilder.HasPartitionKey(name == null ? null : [name], fromDataAnnotation); - - /// - /// Returns a value indicating whether the property that is used to store the partition key can be set - /// from the current configuration source - /// - /// - /// See Modeling entity types and relationships, and - /// Accessing Azure Cosmos DB with EF Core for more information and examples. - /// - /// The builder for the entity type being configured. - /// The name of the partition key property. - /// Indicates whether the configuration was specified using a data annotation. - /// if the configuration can be applied. - [Obsolete("Use HasPartitionKey(IReadOnlyList, bool)")] - public static bool CanSetPartitionKey( - this IConventionEntityTypeBuilder entityTypeBuilder, - string? name, - bool fromDataAnnotation = false) - => entityTypeBuilder.CanSetPartitionKey(name == null ? null : [name], fromDataAnnotation); - /// /// Configures the properties that are used to store the parts of a /// hierarchical partition key. diff --git a/src/EFCore.Cosmos/Extensions/CosmosEntityTypeExtensions.cs b/src/EFCore.Cosmos/Extensions/CosmosEntityTypeExtensions.cs index 4c531cd37c1..78c44f77ef0 100644 --- a/src/EFCore.Cosmos/Extensions/CosmosEntityTypeExtensions.cs +++ b/src/EFCore.Cosmos/Extensions/CosmosEntityTypeExtensions.cs @@ -118,82 +118,6 @@ public static void SetContainingPropertyName(this IMutableEntityType entityType, => entityType.FindAnnotation(CosmosAnnotationNames.PropertyName) ?.GetConfigurationSource(); - /// - /// Returns the name of the property that is used to store the partition key. - /// - /// The entity type to get the partition key property name for. - /// The name of the partition key property. - [Obsolete("Use SetPartitionKeyPropertyNames")] - public static string? GetPartitionKeyPropertyName(this IReadOnlyEntityType entityType) - => entityType.GetPartitionKeyPropertyNames().FirstOrDefault(); - - /// - /// Sets the name of the property that is used to store the partition key key. - /// - /// The entity type to set the partition key property name for. - /// The name to set. - [Obsolete("Use SetPartitionKeyPropertyNames")] - public static void SetPartitionKeyPropertyName(this IMutableEntityType entityType, string? name) - => entityType.SetPartitionKeyPropertyNames(name == null ? null : [name]); - - /// - /// Sets the name of the property that is used to store the partition key. - /// - /// The entity type to set the partition key property name for. - /// The name to set. - /// Indicates whether the configuration was specified using a data annotation. - [Obsolete("Use SetPartitionKeyPropertyNames")] - public static string? SetPartitionKeyPropertyName( - this IConventionEntityType entityType, - string? name, - bool fromDataAnnotation = false) - => entityType.SetPartitionKeyPropertyNames(name is null ? null : [name], fromDataAnnotation)?.FirstOrDefault(); - - /// - /// Gets the for the property that is used to store the partition key. - /// - /// The entity type to find configuration source for. - /// The for the partition key property. - [Obsolete("Use GetPartitionKeyPropertyNamesConfigurationSource")] - public static ConfigurationSource? GetPartitionKeyPropertyNameConfigurationSource(this IConventionEntityType entityType) - => entityType.GetPartitionKeyPropertyNamesConfigurationSource(); - - /// - /// Returns the property that is used to store the partition key. - /// - /// The entity type to get the partition key property for. - /// The name of the partition key property. - [Obsolete("Use GetPartitionKeyProperties")] - public static IReadOnlyProperty? GetPartitionKeyProperty(this IReadOnlyEntityType entityType) - => entityType.GetPartitionKeyProperties().FirstOrDefault(); - - /// - /// Returns the property that is used to store the partition key. - /// - /// The entity type to get the partition key property for. - /// The name of the partition key property. - [Obsolete("Use GetPartitionKeyProperties")] - public static IMutableProperty? GetPartitionKeyProperty(this IMutableEntityType entityType) - => entityType.GetPartitionKeyProperties().FirstOrDefault(); - - /// - /// Returns the property that is used to store the partition key. - /// - /// The entity type to get the partition key property for. - /// The name of the partition key property. - [Obsolete("Use GetPartitionKeyProperties")] - public static IConventionProperty? GetPartitionKeyProperty(this IConventionEntityType entityType) - => entityType.GetPartitionKeyProperties().FirstOrDefault(); - - /// - /// Returns the property that is used to store the partition key. - /// - /// The entity type to get the partition key property for. - /// The name of the partition key property. - [Obsolete("Use GetPartitionKeyProperties")] - public static IProperty? GetPartitionKeyProperty(this IEntityType entityType) - => entityType.GetPartitionKeyProperties().FirstOrDefault(); - /// /// Returns the names of the properties that are used to store the hierarchical partition key, if any. /// diff --git a/src/EFCore.Design/EFCore.Design.baseline.json b/src/EFCore.Design/EFCore.Design.baseline.json index e5ef02eed6e..ab50b4bc010 100644 --- a/src/EFCore.Design/EFCore.Design.baseline.json +++ b/src/EFCore.Design/EFCore.Design.baseline.json @@ -587,10 +587,6 @@ { "Type": "interface Microsoft.EntityFrameworkCore.Scaffolding.IModelCodeGeneratorSelector", "Methods": [ - { - "Member": "Microsoft.EntityFrameworkCore.Scaffolding.IModelCodeGenerator Select(string? language);", - "Stage": "Obsolete" - }, { "Member": "Microsoft.EntityFrameworkCore.Scaffolding.IModelCodeGenerator Select(Microsoft.EntityFrameworkCore.Scaffolding.ModelCodeGenerationOptions options);" } @@ -784,10 +780,6 @@ "Properties": [ { "Member": "Microsoft.EntityFrameworkCore.Design.IAnnotationCodeGenerator AnnotationCodeGenerator { get; init; }" - }, - { - "Member": "Microsoft.EntityFrameworkCore.Storage.IRelationalTypeMappingSource RelationalTypeMappingSource { get; init; }", - "Stage": "Obsolete" } ] }, diff --git a/src/EFCore.Design/Migrations/Design/MigrationsCodeGeneratorDependencies.cs b/src/EFCore.Design/Migrations/Design/MigrationsCodeGeneratorDependencies.cs index d90079599a2..4dcae0f2e48 100644 --- a/src/EFCore.Design/Migrations/Design/MigrationsCodeGeneratorDependencies.cs +++ b/src/EFCore.Design/Migrations/Design/MigrationsCodeGeneratorDependencies.cs @@ -38,21 +38,11 @@ public sealed record MigrationsCodeGeneratorDependencies /// [EntityFrameworkInternal] public MigrationsCodeGeneratorDependencies( - IRelationalTypeMappingSource relationalTypeMappingSource, IAnnotationCodeGenerator annotationCodeGenerator) { -#pragma warning disable CS0612 // Type or member is obsolete - RelationalTypeMappingSource = relationalTypeMappingSource; -#pragma warning restore CS0612 // Type or member is obsolete AnnotationCodeGenerator = annotationCodeGenerator; } - /// - /// The type mapper. - /// - [Obsolete] - public IRelationalTypeMappingSource RelationalTypeMappingSource { get; init; } - /// /// The annotation code generator. /// diff --git a/src/EFCore.Design/Scaffolding/IModelCodeGeneratorSelector.cs b/src/EFCore.Design/Scaffolding/IModelCodeGeneratorSelector.cs index 1e8d73b84a1..fc135a30650 100644 --- a/src/EFCore.Design/Scaffolding/IModelCodeGeneratorSelector.cs +++ b/src/EFCore.Design/Scaffolding/IModelCodeGeneratorSelector.cs @@ -11,21 +11,10 @@ namespace Microsoft.EntityFrameworkCore.Scaffolding; /// public interface IModelCodeGeneratorSelector { - /// - /// Selects an service for a given programming language. - /// - /// The programming language. - /// The . - [Obsolete("Use the overload that takes ModelCodeGenerationOptions instead.")] - IModelCodeGenerator Select(string? language); - /// /// Selects an service for a given set of options. /// /// The options. /// The . - IModelCodeGenerator Select(ModelCodeGenerationOptions options) -#pragma warning disable CS0618 // Type or member is obsolete - => Select(options.Language); -#pragma warning restore CS0618 + IModelCodeGenerator Select(ModelCodeGenerationOptions options); } diff --git a/src/EFCore.InMemory/ValueGeneration/Internal/InMemoryValueGeneratorSelector.cs b/src/EFCore.InMemory/ValueGeneration/Internal/InMemoryValueGeneratorSelector.cs index 75cc565b4cb..e2f325a1c11 100644 --- a/src/EFCore.InMemory/ValueGeneration/Internal/InMemoryValueGeneratorSelector.cs +++ b/src/EFCore.InMemory/ValueGeneration/Internal/InMemoryValueGeneratorSelector.cs @@ -27,24 +27,6 @@ public InMemoryValueGeneratorSelector( : base(dependencies) => _inMemoryStore = inMemoryDatabase.Store; - /// - /// 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. - /// - [Obsolete("Use TrySelect and throw if needed when the generator is not found.")] - public override ValueGenerator? Select(IProperty property, ITypeBase typeBase) - { - if (TrySelect(property, typeBase, out var valueGenerator)) - { - return valueGenerator; - } - - throw new NotSupportedException( - CoreStrings.NoValueGenerator(property.Name, property.DeclaringType.DisplayName(), property.ClrType.ShortDisplayName())); - } - /// /// 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 diff --git a/src/EFCore.Relational/Design/AnnotationCodeGenerator.cs b/src/EFCore.Relational/Design/AnnotationCodeGenerator.cs index a3db3e07d61..3a09933958a 100644 --- a/src/EFCore.Relational/Design/AnnotationCodeGenerator.cs +++ b/src/EFCore.Relational/Design/AnnotationCodeGenerator.cs @@ -35,10 +35,7 @@ public class AnnotationCodeGenerator : IAnnotationCodeGenerator RelationalAnnotationNames.UpdateStoredProcedure, RelationalAnnotationNames.MappingFragments, RelationalAnnotationNames.RelationalOverrides, - RelationalAnnotationNames.JsonElementMappings, -#pragma warning disable CS0618 - RelationalAnnotationNames.ContainerColumnTypeMapping -#pragma warning restore CS0618 + RelationalAnnotationNames.JsonElementMappings }; /// @@ -236,9 +233,6 @@ public virtual IReadOnlyList GenerateFluentApiCalls( containerColumnName)); annotations.Remove(RelationalAnnotationNames.ContainerColumnName); -#pragma warning disable CS0618 - annotations.Remove(RelationalAnnotationNames.ContainerColumnTypeMapping); -#pragma warning restore CS0618 } if (annotations.TryGetValue(RelationalAnnotationNames.ContainerColumnType, out var containerColumnTypeAnnotation) @@ -286,9 +280,6 @@ public virtual IReadOnlyList GenerateFluentApiCalls( containerColumnName)); annotations.Remove(RelationalAnnotationNames.ContainerColumnName); -#pragma warning disable CS0618 - annotations.Remove(RelationalAnnotationNames.ContainerColumnTypeMapping); -#pragma warning restore CS0618 } if (annotations.TryGetValue(RelationalAnnotationNames.ContainerColumnType, out var containerColumnTypeAnnotation) diff --git a/src/EFCore.Relational/Diagnostics/CommandSource.cs b/src/EFCore.Relational/Diagnostics/CommandSource.cs index e7fa5ff0a02..86f9b1484cb 100644 --- a/src/EFCore.Relational/Diagnostics/CommandSource.cs +++ b/src/EFCore.Relational/Diagnostics/CommandSource.cs @@ -63,20 +63,12 @@ public enum CommandSource Scaffolding, /// - /// The command was generated as part of a bulk update. + /// The command was generated as part of an 'ExecuteUpdate' operation. /// - [Obsolete("Use ExecuteDelete or ExecuteUpdate instead.")] - BulkUpdate, + ExecuteUpdate, /// /// The command was generated as part of an 'ExecuteDelete' operation. /// - ExecuteDelete = 9, - - /// - /// The command was generated as part of an 'ExecuteUpdate' operation. - /// -#pragma warning disable CS0618 // Type or member is obsolete - ExecuteUpdate = BulkUpdate, -#pragma warning restore CS0618 // Type or member is obsolete + ExecuteDelete, } diff --git a/src/EFCore.Relational/Diagnostics/RelationalEventId.cs b/src/EFCore.Relational/Diagnostics/RelationalEventId.cs index e69c7e2a8de..0e4524de932 100644 --- a/src/EFCore.Relational/Diagnostics/RelationalEventId.cs +++ b/src/EFCore.Relational/Diagnostics/RelationalEventId.cs @@ -25,100 +25,100 @@ private enum Id { // Connection events ConnectionOpening = CoreEventId.RelationalBaseId, - ConnectionOpened, - ConnectionClosing, - ConnectionClosed, - ConnectionError, - ConnectionCreating, - ConnectionCreated, - ConnectionDisposing, - ConnectionDisposed, - ConnectionCanceled, + ConnectionOpened = CoreEventId.RelationalBaseId + 1, + ConnectionClosing = CoreEventId.RelationalBaseId + 2, + ConnectionClosed = CoreEventId.RelationalBaseId + 3, + ConnectionError = CoreEventId.RelationalBaseId + 4, + ConnectionCreating = CoreEventId.RelationalBaseId + 5, + ConnectionCreated = CoreEventId.RelationalBaseId + 6, + ConnectionDisposing = CoreEventId.RelationalBaseId + 7, + ConnectionDisposed = CoreEventId.RelationalBaseId + 8, + ConnectionCanceled = CoreEventId.RelationalBaseId + 9, // Command events CommandExecuting = CoreEventId.RelationalBaseId + 100, - CommandExecuted, - CommandError, - CommandCreating, - CommandCreated, - CommandCanceled, - CommandInitialized, + CommandExecuted = CoreEventId.RelationalBaseId + 101, + CommandError = CoreEventId.RelationalBaseId + 102, + CommandCreating = CoreEventId.RelationalBaseId + 103, + CommandCreated = CoreEventId.RelationalBaseId + 104, + CommandCanceled = CoreEventId.RelationalBaseId + 105, + CommandInitialized = CoreEventId.RelationalBaseId + 106, // Transaction events TransactionStarted = CoreEventId.RelationalBaseId + 200, - TransactionUsed, - TransactionCommitted, - TransactionRolledBack, - TransactionDisposed, - TransactionError, - AmbientTransactionWarning, - AmbientTransactionEnlisted, - ExplicitTransactionEnlisted, - TransactionStarting, - TransactionCommitting, - TransactionRollingBack, - CreatingTransactionSavepoint, - CreatedTransactionSavepoint, - RollingBackToTransactionSavepoint, - RolledBackToTransactionSavepoint, - ReleasingTransactionSavepoint, - ReleasedTransactionSavepoint, + TransactionUsed = CoreEventId.RelationalBaseId + 201, + TransactionCommitted = CoreEventId.RelationalBaseId + 202, + TransactionRolledBack = CoreEventId.RelationalBaseId + 203, + TransactionDisposed = CoreEventId.RelationalBaseId + 204, + TransactionError = CoreEventId.RelationalBaseId + 205, + AmbientTransactionWarning = CoreEventId.RelationalBaseId + 206, + AmbientTransactionEnlisted = CoreEventId.RelationalBaseId + 207, + ExplicitTransactionEnlisted = CoreEventId.RelationalBaseId + 208, + TransactionStarting = CoreEventId.RelationalBaseId + 209, + TransactionCommitting = CoreEventId.RelationalBaseId + 210, + TransactionRollingBack = CoreEventId.RelationalBaseId + 211, + CreatingTransactionSavepoint = CoreEventId.RelationalBaseId + 212, + CreatedTransactionSavepoint = CoreEventId.RelationalBaseId + 213, + RollingBackToTransactionSavepoint = CoreEventId.RelationalBaseId + 214, + RolledBackToTransactionSavepoint = CoreEventId.RelationalBaseId + 215, + ReleasingTransactionSavepoint = CoreEventId.RelationalBaseId + 216, + ReleasedTransactionSavepoint = CoreEventId.RelationalBaseId + 217, // DataReader events DataReaderDisposing = CoreEventId.RelationalBaseId + 300, - DataReaderClosing, + DataReaderClosing = CoreEventId.RelationalBaseId + 301, // Migrations events MigrateUsingConnection = CoreEventId.RelationalBaseId + 400, - MigrationReverting, - MigrationApplying, - MigrationGeneratingDownScript, - MigrationGeneratingUpScript, - MigrationsNotApplied, - MigrationsNotFound, - MigrationAttributeMissingWarning, - ColumnOrderIgnoredWarning, - PendingModelChangesWarning, - NonTransactionalMigrationOperationWarning, - AcquiringMigrationLock, - MigrationsUserTransactionWarning, - ModelSnapshotNotFound, - OldMigrationVersionWarning, + MigrationReverting = CoreEventId.RelationalBaseId + 401, + MigrationApplying = CoreEventId.RelationalBaseId + 402, + MigrationGeneratingDownScript = CoreEventId.RelationalBaseId + 403, + MigrationGeneratingUpScript = CoreEventId.RelationalBaseId + 404, + MigrationsNotApplied = CoreEventId.RelationalBaseId + 405, + MigrationsNotFound = CoreEventId.RelationalBaseId + 406, + MigrationAttributeMissingWarning = CoreEventId.RelationalBaseId + 407, + ColumnOrderIgnoredWarning = CoreEventId.RelationalBaseId + 408, + PendingModelChangesWarning = CoreEventId.RelationalBaseId + 409, + NonTransactionalMigrationOperationWarning = CoreEventId.RelationalBaseId + 410, + AcquiringMigrationLock = CoreEventId.RelationalBaseId + 411, + MigrationsUserTransactionWarning = CoreEventId.RelationalBaseId + 412, + ModelSnapshotNotFound = CoreEventId.RelationalBaseId + 413, + OldMigrationVersionWarning = CoreEventId.RelationalBaseId + 414, // Query events QueryClientEvaluationWarning = CoreEventId.RelationalBaseId + 500, - QueryPossibleUnintendedUseOfEqualsWarning, + QueryPossibleUnintendedUseOfEqualsWarning = CoreEventId.RelationalBaseId + 501, // ReSharper disable twice InconsistentNaming - Obsolete_QueryPossibleExceptionWithAggregateOperatorWarning, - Obsolete_ValueConversionSqlLiteralWarning, - MultipleCollectionIncludeWarning, - NonQueryOperationFailed, - ExecuteDeleteFailed, - ExecuteUpdateFailed, + Obsolete_QueryPossibleExceptionWithAggregateOperatorWarning = CoreEventId.RelationalBaseId + 502, + Obsolete_ValueConversionSqlLiteralWarning = CoreEventId.RelationalBaseId + 503, + MultipleCollectionIncludeWarning = CoreEventId.RelationalBaseId + 504, + NonQueryOperationFailed = CoreEventId.RelationalBaseId + 505, + ExecuteDeleteFailed = CoreEventId.RelationalBaseId + 506, + ExecuteUpdateFailed = CoreEventId.RelationalBaseId + 507, // Model validation events ModelValidationKeyDefaultValueWarning = CoreEventId.RelationalBaseId + 600, - BoolWithDefaultWarning, - AllIndexPropertiesNotMappedToAnyTable, - IndexPropertiesBothMappedAndNotMappedToTable, - IndexPropertiesMappedToNonOverlappingTables, - ForeignKeyPropertiesMappedToUnrelatedTables, - OptionalDependentWithoutIdentifyingPropertyWarning, - DuplicateColumnOrders, - ForeignKeyTpcPrincipalWarning, - TpcStoreGeneratedIdentityWarning, - KeyPropertiesNotMappedToTable, - StoredProcedureConcurrencyTokenNotMapped, - TriggerOnNonRootTphEntity, + BoolWithDefaultWarning = CoreEventId.RelationalBaseId + 601, + AllIndexPropertiesNotMappedToAnyTable = CoreEventId.RelationalBaseId + 602, + IndexPropertiesBothMappedAndNotMappedToTable = CoreEventId.RelationalBaseId + 603, + IndexPropertiesMappedToNonOverlappingTables = CoreEventId.RelationalBaseId + 604, + ForeignKeyPropertiesMappedToUnrelatedTables = CoreEventId.RelationalBaseId + 605, + OptionalDependentWithoutIdentifyingPropertyWarning = CoreEventId.RelationalBaseId + 606, + DuplicateColumnOrders = CoreEventId.RelationalBaseId + 607, + ForeignKeyTpcPrincipalWarning = CoreEventId.RelationalBaseId + 608, + TpcStoreGeneratedIdentityWarning = CoreEventId.RelationalBaseId + 609, + KeyPropertiesNotMappedToTable = CoreEventId.RelationalBaseId + 610, + StoredProcedureConcurrencyTokenNotMapped = CoreEventId.RelationalBaseId + 611, + TriggerOnNonRootTphEntity = CoreEventId.RelationalBaseId + 612, // Update events BatchReadyForExecution = CoreEventId.RelationalBaseId + 700, - BatchSmallerThanMinBatchSize, - BatchExecutorFailedToRollbackToSavepoint, - BatchExecutorFailedToReleaseSavepoint, - OptionalDependentWithAllNullPropertiesWarning, - UnexpectedTrailingResultSetWhenSaving, + BatchSmallerThanMinBatchSize = CoreEventId.RelationalBaseId + 701, + BatchExecutorFailedToRollbackToSavepoint = CoreEventId.RelationalBaseId + 702, + BatchExecutorFailedToReleaseSavepoint = CoreEventId.RelationalBaseId + 703, + OptionalDependentWithAllNullPropertiesWarning = CoreEventId.RelationalBaseId + 704, + UnexpectedTrailingResultSetWhenSaving = CoreEventId.RelationalBaseId + 705, } private static readonly string _connectionPrefix = DbLoggerCategory.Database.Connection.Name + "."; diff --git a/src/EFCore.Relational/EFCore.Relational.baseline.json b/src/EFCore.Relational/EFCore.Relational.baseline.json index 0fbf32cb4c4..daf6aa056f7 100644 --- a/src/EFCore.Relational/EFCore.Relational.baseline.json +++ b/src/EFCore.Relational/EFCore.Relational.baseline.json @@ -774,17 +774,9 @@ { "Member": "virtual System.Type ElementType { get; }" }, - { - "Member": "virtual Microsoft.EntityFrameworkCore.Metadata.INavigationBase? Navigation { get; }", - "Stage": "Obsolete" - }, { "Member": "override System.Linq.Expressions.ExpressionType NodeType { get; }" }, - { - "Member": "virtual Microsoft.EntityFrameworkCore.Query.ProjectionBindingExpression ProjectionBindingExpression { get; }", - "Stage": "Obsolete" - }, { "Member": "virtual System.Linq.Expressions.Expression QueryExpression { get; }" }, @@ -1306,11 +1298,6 @@ } ], "Fields": [ - { - "Member": "const Microsoft.EntityFrameworkCore.Diagnostics.CommandSource BulkUpdate", - "Stage": "Obsolete", - "Value": "8" - }, { "Member": "const Microsoft.EntityFrameworkCore.Diagnostics.CommandSource ExecuteDelete", "Value": "9" @@ -5894,10 +5881,6 @@ }, { "Member": "System.Collections.Generic.IReadOnlyList Parameters { get; }" - }, - { - "Member": "Microsoft.EntityFrameworkCore.Storage.IRelationalTypeMappingSource TypeMappingSource { get; }", - "Stage": "Obsolete" } ] }, @@ -6874,10 +6857,6 @@ }, { "Member": "string StoreType { get; }" - }, - { - "Member": "string Type { get; }", - "Stage": "Obsolete" } ] }, @@ -9953,11 +9932,6 @@ "Member": "const string ContainerColumnType", "Value": "Relational:ContainerColumnType" }, - { - "Member": "const string ContainerColumnTypeMapping", - "Stage": "Obsolete", - "Value": "Relational:ContainerColumnTypeMapping" - }, { "Member": "const string DbFunctions", "Value": "Relational:DbFunctions" @@ -10470,10 +10444,6 @@ }, { "Member": "virtual System.Collections.Generic.IReadOnlyList Parameters { get; }" - }, - { - "Member": "virtual Microsoft.EntityFrameworkCore.Storage.IRelationalTypeMappingSource TypeMappingSource { get; }", - "Stage": "Obsolete" } ] }, @@ -10508,10 +10478,6 @@ }, { "Member": "Microsoft.EntityFrameworkCore.Diagnostics.ILoggingOptions LoggingOptions { get; init; }" - }, - { - "Member": "Microsoft.EntityFrameworkCore.Storage.IRelationalTypeMappingSource TypeMappingSource { get; init; }", - "Stage": "Obsolete" } ] }, @@ -10521,10 +10487,6 @@ { "Member": "static Microsoft.EntityFrameworkCore.Storage.IRelationalCommandBuilder AddCompositeParameter(this Microsoft.EntityFrameworkCore.Storage.IRelationalCommandBuilder commandBuilder, string invariantName, System.Collections.Generic.IReadOnlyList subParameters);" }, - { - "Member": "static Microsoft.EntityFrameworkCore.Storage.IRelationalCommandBuilder AddParameter(this Microsoft.EntityFrameworkCore.Storage.IRelationalCommandBuilder commandBuilder, string invariantName, string name);", - "Stage": "Obsolete" - }, { "Member": "static Microsoft.EntityFrameworkCore.Storage.IRelationalCommandBuilder AddParameter(this Microsoft.EntityFrameworkCore.Storage.IRelationalCommandBuilder commandBuilder, string invariantName, string name, Microsoft.EntityFrameworkCore.Storage.RelationalTypeMapping relationalTypeMapping, bool? nullable, System.Data.ParameterDirection direction = System.Data.ParameterDirection.Input);" }, @@ -11217,11 +11179,7 @@ "Type": "class Microsoft.EntityFrameworkCore.Storage.ValueConversion.RelationalConverterMappingHints : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints", "Methods": [ { - "Member": "RelationalConverterMappingHints(int? size = null, int? precision = null, int? scale = null, bool? unicode = null, bool? fixedLength = null, System.Func? valueGeneratorFactory = null, System.Data.DbType? dbType = null);" - }, - { - "Member": "RelationalConverterMappingHints(int? size, int? precision, int? scale, bool? unicode, bool? fixedLength, System.Func? valueGeneratorFactory);", - "Stage": "Obsolete" + "Member": "RelationalConverterMappingHints(int? size = null, int? precision = null, int? scale = null, bool? unicode = null, bool? fixedLength = null, System.Data.DbType? dbType = null);" }, { "Member": "override Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints OverrideWith(Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints? hints);" @@ -11626,14 +11584,6 @@ { "Member": "override string? ToString();" }, - { - "Member": "virtual TBuilder TranslateParameterizedCollectionsToConstants();", - "Stage": "Obsolete" - }, - { - "Member": "virtual TBuilder TranslateParameterizedCollectionsToParameters();", - "Stage": "Obsolete" - }, { "Member": "virtual TBuilder UseParameterizedCollectionMode(Microsoft.EntityFrameworkCore.ParameterTranslationMode parameterizedCollectionMode);" }, @@ -12290,14 +12240,6 @@ { "Member": "static Microsoft.EntityFrameworkCore.Metadata.ConfigurationSource? GetCommentConfigurationSource(this Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType entityType);" }, - { - "Member": "static Microsoft.EntityFrameworkCore.Storage.RelationalTypeMapping? GetContainerColumnTypeMapping(this Microsoft.EntityFrameworkCore.Metadata.IReadOnlyEntityType entityType);", - "Stage": "Obsolete" - }, - { - "Member": "static Microsoft.EntityFrameworkCore.Metadata.ConfigurationSource? GetContainerColumnTypeMappingConfigurationSource(this Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType entityType);", - "Stage": "Obsolete" - }, { "Member": "static System.Collections.Generic.IEnumerable GetDeclaredCheckConstraints(this Microsoft.EntityFrameworkCore.Metadata.IReadOnlyEntityType entityType);" }, @@ -12505,14 +12447,6 @@ { "Member": "static string? SetComment(this Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType entityType, string? comment, bool fromDataAnnotation = false);" }, - { - "Member": "static void SetContainerColumnTypeMapping(this Microsoft.EntityFrameworkCore.Metadata.IMutableEntityType entityType, Microsoft.EntityFrameworkCore.Storage.RelationalTypeMapping typeMapping);", - "Stage": "Obsolete" - }, - { - "Member": "static Microsoft.EntityFrameworkCore.Storage.RelationalTypeMapping? SetContainerColumnTypeMapping(this Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType entityType, Microsoft.EntityFrameworkCore.Storage.RelationalTypeMapping? typeMapping, bool fromDataAnnotation = false);", - "Stage": "Obsolete" - }, { "Member": "static Microsoft.EntityFrameworkCore.Metadata.IMutableStoredProcedure SetDeleteStoredProcedure(this Microsoft.EntityFrameworkCore.Metadata.IMutableEntityType entityType);" }, @@ -13623,15 +13557,11 @@ ] }, { - "Type": "class Microsoft.EntityFrameworkCore.Metadata.Conventions.RelationalMapToJsonConvention : Microsoft.EntityFrameworkCore.Metadata.Conventions.IEntityTypeAnnotationChangedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IModelFinalizingConvention", + "Type": "class Microsoft.EntityFrameworkCore.Metadata.Conventions.RelationalMapToJsonConvention : Microsoft.EntityFrameworkCore.Metadata.Conventions.IModelFinalizingConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IConvention", "Methods": [ { "Member": "RelationalMapToJsonConvention(Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure.ProviderConventionSetBuilderDependencies dependencies, Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure.RelationalConventionSetBuilderDependencies relationalDependencies);" }, - { - "Member": "virtual void ProcessEntityTypeAnnotationChanged(Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionEntityTypeBuilder entityTypeBuilder, string name, Microsoft.EntityFrameworkCore.Metadata.IConventionAnnotation? annotation, Microsoft.EntityFrameworkCore.Metadata.IConventionAnnotation? oldAnnotation, Microsoft.EntityFrameworkCore.Metadata.Conventions.IConventionContext context);", - "Stage": "Obsolete" - }, { "Member": "virtual void ProcessModelFinalizing(Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionModelBuilder modelBuilder, Microsoft.EntityFrameworkCore.Metadata.Conventions.IConventionContext context);" } @@ -14578,10 +14508,6 @@ { "Member": "virtual System.Linq.Expressions.Expression ExpandFromSqlParameter(System.Linq.Expressions.Expression queryExpression, Microsoft.EntityFrameworkCore.Query.ParametersCacheDecorator decorator);" }, - { - "Member": "virtual System.Linq.Expressions.Expression Optimize(System.Linq.Expressions.Expression queryExpression, System.Collections.Generic.IReadOnlyDictionary parametersValues, out bool canCache);", - "Stage": "Obsolete" - }, { "Member": "virtual System.Linq.Expressions.Expression Process(System.Linq.Expressions.Expression queryExpression, Microsoft.EntityFrameworkCore.Query.ParametersCacheDecorator parametersDecorator);" }, @@ -14990,10 +14916,6 @@ { "Member": "static Microsoft.EntityFrameworkCore.Metadata.ConfigurationSource? GetCollationConfigurationSource(this Microsoft.EntityFrameworkCore.Metadata.IConventionProperty property);" }, - { - "Member": "static string GetColumnBaseName(this Microsoft.EntityFrameworkCore.Metadata.IReadOnlyProperty property);", - "Stage": "Obsolete" - }, { "Member": "static string GetColumnName(this Microsoft.EntityFrameworkCore.Metadata.IReadOnlyProperty property);" }, @@ -15048,10 +14970,6 @@ { "Member": "static Microsoft.EntityFrameworkCore.Metadata.ConfigurationSource? GetComputedColumnSqlConfigurationSource(this Microsoft.EntityFrameworkCore.Metadata.IConventionProperty property);" }, - { - "Member": "static string GetDefaultColumnBaseName(this Microsoft.EntityFrameworkCore.Metadata.IReadOnlyProperty property);", - "Stage": "Obsolete" - }, { "Member": "static System.Collections.Generic.IEnumerable GetDefaultColumnMappings(this Microsoft.EntityFrameworkCore.Metadata.IPropertyBase propertyBase);" }, @@ -15363,10 +15281,6 @@ { "Member": "virtual bool IsValidSelectExpressionForExecuteDelete(Microsoft.EntityFrameworkCore.Query.SqlExpressions.SelectExpression selectExpression);" }, - { - "Member": "virtual bool IsValidSelectExpressionForExecuteDelete(Microsoft.EntityFrameworkCore.Query.SqlExpressions.SelectExpression selectExpression, Microsoft.EntityFrameworkCore.Query.StructuralTypeShaperExpression shaper, out Microsoft.EntityFrameworkCore.Query.SqlExpressions.TableExpression? tableExpression);", - "Stage": "Obsolete" - }, { "Member": "virtual bool IsValidSelectExpressionForExecuteUpdate(Microsoft.EntityFrameworkCore.Query.SqlExpressions.SelectExpression selectExpression, Microsoft.EntityFrameworkCore.Query.SqlExpressions.TableExpressionBase targetTable, out Microsoft.EntityFrameworkCore.Query.SqlExpressions.TableExpression? tableExpression);" }, @@ -15525,16 +15439,6 @@ } ] }, - { - "Type": "class Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.RelationalInferredTypeMappingApplier", - "Stage": "Obsolete", - "Methods": [ - { - "Member": "RelationalInferredTypeMappingApplier();", - "Stage": "Obsolete" - } - ] - }, { "Type": "sealed record Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitorDependencies", "Methods": [ @@ -17037,8 +16941,7 @@ ], "Properties": [ { - "Member": "static string BadSequenceString { get; }", - "Stage": "Obsolete" + "Member": "static string BadSequenceString { get; }" }, { "Member": "static string BadSequenceType { get; }" @@ -19009,10 +18912,6 @@ { "Member": "SqlConstantExpression(object value, bool sensitive, Microsoft.EntityFrameworkCore.Storage.RelationalTypeMapping? typeMapping);" }, - { - "Member": "SqlConstantExpression(System.Linq.Expressions.ConstantExpression constantExpression, Microsoft.EntityFrameworkCore.Storage.RelationalTypeMapping? typeMapping);", - "Stage": "Obsolete" - }, { "Member": "virtual Microsoft.EntityFrameworkCore.Query.SqlExpressions.SqlExpression ApplyTypeMapping(Microsoft.EntityFrameworkCore.Storage.RelationalTypeMapping? typeMapping);" }, diff --git a/src/EFCore.Relational/Extensions/RelationalEntityTypeExtensions.cs b/src/EFCore.Relational/Extensions/RelationalEntityTypeExtensions.cs index 1f349709a59..42a680fe71e 100644 --- a/src/EFCore.Relational/Extensions/RelationalEntityTypeExtensions.cs +++ b/src/EFCore.Relational/Extensions/RelationalEntityTypeExtensions.cs @@ -1580,51 +1580,6 @@ public static void SetMappingStrategy(this IMutableEntityType entityType, string public static bool IsMappedToJson(this IReadOnlyEntityType entityType) => !string.IsNullOrEmpty(entityType.GetContainerColumnName()); - /// - /// Sets the type mapping for the container column to which the entity type is mapped. - /// - /// The entity type to set the container column type mapping for. - /// The type mapping to set. - [Obsolete("Container column mappings are now obtained from IColumnBase.StoreTypeMapping")] - public static void SetContainerColumnTypeMapping(this IMutableEntityType entityType, RelationalTypeMapping typeMapping) - => entityType.SetOrRemoveAnnotation(RelationalAnnotationNames.ContainerColumnTypeMapping, typeMapping); - - /// - /// Sets the type mapping for the container column to which the entity type is mapped. - /// - /// The entity type to set the container column type mapping for. - /// The type mapping to set. - /// Indicates whether the configuration was specified using a data annotation. - /// The configured value. - [Obsolete("Container column mappings are now obtained from IColumnBase.StoreTypeMapping")] - public static RelationalTypeMapping? SetContainerColumnTypeMapping( - this IConventionEntityType entityType, - RelationalTypeMapping? typeMapping, - bool fromDataAnnotation = false) - => (RelationalTypeMapping?)entityType.SetAnnotation( - RelationalAnnotationNames.ContainerColumnTypeMapping, typeMapping, fromDataAnnotation)?.Value; - - /// - /// Gets the for the container column type mapping. - /// - /// The entity type to set the container column type mapping for. - /// The for the container column type mapping. - [Obsolete("Container column mappings are now obtained from IColumnBase.StoreTypeMapping")] - public static ConfigurationSource? GetContainerColumnTypeMappingConfigurationSource(this IConventionEntityType entityType) - => entityType.FindAnnotation(RelationalAnnotationNames.ContainerColumnTypeMapping) - ?.GetConfigurationSource(); - - /// - /// Gets the container column type mapping to which the entity type is mapped. - /// - /// The entity type to get the container column type mapping for. - /// The container column type mapping to which the entity type is mapped. - [Obsolete("Container column mappings are now obtained from IColumnBase.StoreTypeMapping")] - public static RelationalTypeMapping? GetContainerColumnTypeMapping(this IReadOnlyEntityType entityType) - => entityType.FindAnnotation(RelationalAnnotationNames.ContainerColumnTypeMapping)?.Value is RelationalTypeMapping typeMapping - ? typeMapping - : (entityType.FindOwnership()?.PrincipalEntityType.GetContainerColumnTypeMapping()); - /// /// Sets the value of JSON property name used for the given entity mapped to a JSON column. /// diff --git a/src/EFCore.Relational/Extensions/RelationalPropertyExtensions.cs b/src/EFCore.Relational/Extensions/RelationalPropertyExtensions.cs index 8fc0ecc362b..58e00ff9355 100644 --- a/src/EFCore.Relational/Extensions/RelationalPropertyExtensions.cs +++ b/src/EFCore.Relational/Extensions/RelationalPropertyExtensions.cs @@ -28,15 +28,6 @@ public static class RelationalPropertyExtensions private static readonly MethodInfo ThrowReadValueExceptionMethod = typeof(RelationalPropertyExtensions).GetTypeInfo().GetDeclaredMethod(nameof(ThrowReadValueException))!; - /// - /// Returns the base name of the column to which the property would be mapped. - /// - /// The property. - /// The base name of the column to which the property would be mapped. - [Obsolete("Use GetColumnName")] - public static string GetColumnBaseName(this IReadOnlyProperty property) - => property.GetColumnName(); - /// /// Returns the name of the column to which the property would be mapped. /// @@ -162,15 +153,6 @@ static bool ShouldBeMapped(IReadOnlyProperty property, in StoreObjectIdentifier } } - /// - /// Returns the default base name of the column to which the property would be mapped - /// - /// The property. - /// The default base column name to which the property would be mapped. - [Obsolete("Use GetDefaultColumnName")] - public static string GetDefaultColumnBaseName(this IReadOnlyProperty property) - => property.GetDefaultColumnName(); - /// /// Returns the default base name of the column to which the property would be mapped /// diff --git a/src/EFCore.Relational/Infrastructure/RelationalDbContextOptionsBuilder.cs b/src/EFCore.Relational/Infrastructure/RelationalDbContextOptionsBuilder.cs index 424276901a1..a3aac7672be 100644 --- a/src/EFCore.Relational/Infrastructure/RelationalDbContextOptionsBuilder.cs +++ b/src/EFCore.Relational/Infrastructure/RelationalDbContextOptionsBuilder.cs @@ -156,54 +156,6 @@ public virtual TBuilder ExecutionStrategy( Func getExecutionStrategy) => WithOption(e => (TExtension)e.WithExecutionStrategyFactory(Check.NotNull(getExecutionStrategy))); - /// - /// Configures the context to translate parameterized collections to inline constants. - /// - /// - /// - /// When a LINQ query contains a parameterized collection, by default EF Core translates as a multiple SQL parameters, - /// if possible. For example, on SQL Server, the LINQ query Where(b => ids.Contains(b.Id) is translated to - /// WHERE [b].[Id] IN (@ids1, @ids2, @ids3). - /// - /// - /// instructs EF to translate the collection to a set of constants: - /// WHERE [b].[Id] IN (1, 2, 3). This can produce better query plans for certain query types, but can also lead to query - /// plan bloat. - /// - /// - /// Note that it's possible to cause EF to translate a specific collection in a specific query to constants by wrapping the - /// parameterized collection in : Where(b => EF.Constant(ids).Contains(b.Id). This overrides - /// the default. - /// - /// - [Obsolete("Use UseParameterizedCollectionMode instead.")] - public virtual TBuilder TranslateParameterizedCollectionsToConstants() - => UseParameterizedCollectionMode(ParameterTranslationMode.Constant); - - /// - /// Configures the context to translate parameterized collections to a single array-like parameter. - /// - /// - /// - /// When a LINQ query contains a parameterized collection, by default EF Core translates as a multiple SQL parameters, - /// if possible. For example, on SQL Server, the LINQ query Where(b => ids.Contains(b.Id) is translated to - /// WHERE [b].[Id] IN (@ids1, @ids2, @ids3). - /// - /// - /// instructs EF to translate the collection to a single array-like - /// parameter: - /// WHERE [b].[Id] IN (SELECT [i].[value] FROM OPENJSON(@ids) ...). - /// - /// - /// Note that it's possible to cause EF to translate a specific collection in a specific query to parameter by wrapping the - /// parameterized collection in : Where(b => EF.Parameter(ids).Contains(b.Id). This overrides - /// the default. - /// - /// - [Obsolete("Use UseParameterizedCollectionMode instead.")] - public virtual TBuilder TranslateParameterizedCollectionsToParameters() - => UseParameterizedCollectionMode(ParameterTranslationMode.Parameter); - /// /// Configures the mode to use when translating parameterized collections. /// diff --git a/src/EFCore.Relational/Metadata/Conventions/RelationalMapToJsonConvention.cs b/src/EFCore.Relational/Metadata/Conventions/RelationalMapToJsonConvention.cs index 41ccc57d379..385fe72fc6f 100644 --- a/src/EFCore.Relational/Metadata/Conventions/RelationalMapToJsonConvention.cs +++ b/src/EFCore.Relational/Metadata/Conventions/RelationalMapToJsonConvention.cs @@ -11,7 +11,7 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Conventions; /// /// See Model building conventions for more information and examples. /// -public class RelationalMapToJsonConvention : IEntityTypeAnnotationChangedConvention, IModelFinalizingConvention +public class RelationalMapToJsonConvention : IModelFinalizingConvention { /// /// Creates a new instance of . @@ -36,17 +36,6 @@ public RelationalMapToJsonConvention( /// protected virtual RelationalConventionSetBuilderDependencies RelationalDependencies { get; } - /// - [Obsolete("Container column mappings are now obtained from IColumnBase.StoreTypeMapping")] - public virtual void ProcessEntityTypeAnnotationChanged( - IConventionEntityTypeBuilder entityTypeBuilder, - string name, - IConventionAnnotation? annotation, - IConventionAnnotation? oldAnnotation, - IConventionContext context) - { - } - /// public virtual void ProcessModelFinalizing( IConventionModelBuilder modelBuilder, diff --git a/src/EFCore.Relational/Metadata/IStoreFunctionParameter.cs b/src/EFCore.Relational/Metadata/IStoreFunctionParameter.cs index 2fd5cb82a71..2af5a0fb494 100644 --- a/src/EFCore.Relational/Metadata/IStoreFunctionParameter.cs +++ b/src/EFCore.Relational/Metadata/IStoreFunctionParameter.cs @@ -33,13 +33,6 @@ public interface IStoreFunctionParameter : IAnnotatable /// string StoreType { get; } - /// - /// Gets the store type of this parameter. - /// - [Obsolete("Use " + nameof(StoreType) + " instead.")] - string Type - => StoreType; - /// /// /// Creates a human-readable representation of the given metadata. diff --git a/src/EFCore.Relational/Metadata/RelationalAnnotationNames.cs b/src/EFCore.Relational/Metadata/RelationalAnnotationNames.cs index 32e60960ffd..4dbc77b80cc 100644 --- a/src/EFCore.Relational/Metadata/RelationalAnnotationNames.cs +++ b/src/EFCore.Relational/Metadata/RelationalAnnotationNames.cs @@ -344,12 +344,6 @@ public static class RelationalAnnotationNames /// public const string ContainerColumnType = Prefix + nameof(ContainerColumnType); - /// - /// The name for the annotation specifying container column type mapping. - /// - [Obsolete("Container column mappings are now obtained from IColumnBase.StoreTypeMapping")] - public const string ContainerColumnTypeMapping = Prefix + "ContainerColumnTypeMapping"; - /// /// The JSON property name for the element that the property/navigation maps to. /// @@ -437,9 +431,6 @@ public static class RelationalAnnotationNames FieldValueGetter, ContainerColumnName, ContainerColumnType, -#pragma warning disable CS0618 // Type or member is obsolete - ContainerColumnTypeMapping, -#pragma warning restore CS0618 // Type or member is obsolete JsonPropertyName, StoreType, JsonElementMappings diff --git a/src/EFCore.Relational/Query/CollectionResultExpression.cs b/src/EFCore.Relational/Query/CollectionResultExpression.cs index d866c5f1111..7df728485ee 100644 --- a/src/EFCore.Relational/Query/CollectionResultExpression.cs +++ b/src/EFCore.Relational/Query/CollectionResultExpression.cs @@ -78,16 +78,4 @@ public virtual void Print(ExpressionPrinter expressionPrinter) expressionPrinter.Append("ElementType:").AppendLine(ElementType.ShortDisplayName()); } } - - /// - /// The expression to get the subquery for this collection. - /// - [Obsolete("Use QueryExpression instead.", error: true)] - public virtual ProjectionBindingExpression ProjectionBindingExpression { get; } = null!; - - /// - /// The navigation if associated with the collection. - /// - [Obsolete("Use StructuralProperty instead.", error: true)] - public virtual INavigationBase? Navigation { get; } } diff --git a/src/EFCore.Relational/Query/RelationalParameterBasedSqlProcessor.cs b/src/EFCore.Relational/Query/RelationalParameterBasedSqlProcessor.cs index d1017408e5e..6750f3cc5d0 100644 --- a/src/EFCore.Relational/Query/RelationalParameterBasedSqlProcessor.cs +++ b/src/EFCore.Relational/Query/RelationalParameterBasedSqlProcessor.cs @@ -87,18 +87,4 @@ protected virtual Expression ProcessSqlNullability(Expression queryExpression, P /// A processed query expression. protected virtual Expression ExpandFromSqlParameter(Expression queryExpression, ParametersCacheDecorator decorator) => new RelationalParameterProcessor(Dependencies).Expand(queryExpression, decorator); - - /// - /// Optimizes the query expression for given parameter values. - /// - /// A query expression to optimize. - /// A dictionary of parameter values to use. - /// A bool value indicating if the query expression can be cached. - /// An optimized query expression. - [Obsolete("Override Process() instead", error: true)] - public virtual Expression Optimize( - Expression queryExpression, - IReadOnlyDictionary parametersValues, - out bool canCache) - => throw new UnreachableException(); } diff --git a/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.ExecuteDelete.cs b/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.ExecuteDelete.cs index 8d3ee65d273..3a9393b4cfd 100644 --- a/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.ExecuteDelete.cs +++ b/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.ExecuteDelete.cs @@ -188,14 +188,4 @@ protected virtual bool IsValidSelectExpressionForExecuteDelete(SelectExpression GroupBy: [], Having: null }; - - /// - /// This method has been obsoleted, use the method accepting a single SelectExpression parameter instead. - /// - [Obsolete("This method has been obsoleted, use the method accepting a single SelectExpression parameter instead.", error: true)] - protected virtual bool IsValidSelectExpressionForExecuteDelete( - SelectExpression selectExpression, - StructuralTypeShaperExpression shaper, - [NotNullWhen(true)] out TableExpression? tableExpression) - => throw new UnreachableException(); } diff --git a/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs index 8c796cc69f9..bc3f88391ee 100644 --- a/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs @@ -2479,14 +2479,6 @@ private ShapedQueryExpression CreateShapedQueryExpressionForValuesExpression( () => typeof(RelationalQueryableMethodTranslatingExpressionVisitor) .GetMethod(nameof(FakeDefaultIfEmpty), BindingFlags.NonPublic | BindingFlags.Static)!); - /// - /// This visitor has been obsoleted; Extend RelationalTypeMappingPostprocessor instead, and invoke it from - /// . - /// - [Obsolete( - "Extend RelationalTypeMappingPostprocessor instead, and invoke it from RelationalQueryTranslationPostprocessor.ProcessTypeMappings().")] - protected class RelationalInferredTypeMappingApplier; - /// /// Determines whether a join is guaranteed to match at most one inner row per outer row (a "to-one" join). /// This is detected by checking whether the inner key selector's properties form a primary/alternate key diff --git a/src/EFCore.Relational/Query/SqlExpressions/SqlConstantExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/SqlConstantExpression.cs index f6bc6b3980d..d51d32409e9 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/SqlConstantExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/SqlConstantExpression.cs @@ -64,17 +64,6 @@ public SqlConstantExpression(object value, bool sensitive, RelationalTypeMapping { } - /// - /// Creates a new instance of the class. - /// - /// A . - /// The associated with the expression. - [Obsolete("Call the constructor accepting a value (and possibly a Type) instead")] - public SqlConstantExpression(ConstantExpression constantExpression, RelationalTypeMapping? typeMapping) - : this(constantExpression.Value, constantExpression.Type, sensitive: false, typeMapping) - { - } - /// /// The constant value. /// diff --git a/src/EFCore.Relational/Storage/IRelationalCommandBuilder.cs b/src/EFCore.Relational/Storage/IRelationalCommandBuilder.cs index cc9426cbc22..d544877dc58 100644 --- a/src/EFCore.Relational/Storage/IRelationalCommandBuilder.cs +++ b/src/EFCore.Relational/Storage/IRelationalCommandBuilder.cs @@ -37,12 +37,6 @@ public interface IRelationalCommandBuilder /// The same builder instance so that multiple calls can be chained. IRelationalCommandBuilder RemoveParameterAt(int index); - /// - /// The source for s to use. - /// - [Obsolete("Code trying to add parameter should add type mapped parameter using TypeMappingSource directly.")] - IRelationalTypeMappingSource TypeMappingSource { get; } - /// /// Creates the command. /// diff --git a/src/EFCore.Relational/Storage/IRelationalTypeMappingSource.cs b/src/EFCore.Relational/Storage/IRelationalTypeMappingSource.cs index ae1f2866017..7e9e2cfc068 100644 --- a/src/EFCore.Relational/Storage/IRelationalTypeMappingSource.cs +++ b/src/EFCore.Relational/Storage/IRelationalTypeMappingSource.cs @@ -45,7 +45,7 @@ public interface IRelationalTypeMappingSource : ITypeMappingSource /// /// The field or property. /// The type mapping, or if none was found. - new RelationalTypeMapping? FindMapping(MemberInfo member); + RelationalTypeMapping? FindMapping(MemberInfo member); /// /// Finds the type mapping for a given . diff --git a/src/EFCore.Relational/Storage/RelationalCommandBuilder.cs b/src/EFCore.Relational/Storage/RelationalCommandBuilder.cs index 4fbc4cd185c..413ed86b1f4 100644 --- a/src/EFCore.Relational/Storage/RelationalCommandBuilder.cs +++ b/src/EFCore.Relational/Storage/RelationalCommandBuilder.cs @@ -29,11 +29,6 @@ public RelationalCommandBuilder( /// protected virtual RelationalCommandBuilderDependencies Dependencies { get; } - /// - [Obsolete("Code trying to add parameter should add type mapped parameter using TypeMappingSource directly.")] - public virtual IRelationalTypeMappingSource TypeMappingSource - => Dependencies.TypeMappingSource; - /// public virtual IRelationalCommand Build() { diff --git a/src/EFCore.Relational/Storage/RelationalCommandBuilderDependencies.cs b/src/EFCore.Relational/Storage/RelationalCommandBuilderDependencies.cs index 3db84e30c0c..82992a3baf4 100644 --- a/src/EFCore.Relational/Storage/RelationalCommandBuilderDependencies.cs +++ b/src/EFCore.Relational/Storage/RelationalCommandBuilderDependencies.cs @@ -51,10 +51,6 @@ public RelationalCommandBuilderDependencies( { ExceptionDetector = exceptionDetector; LoggingOptions = loggingOptions; - -#pragma warning disable CS0618 // Type or member is obsolete - TypeMappingSource = typeMappingSource; -#pragma warning restore CS0618 // Type or member is obsolete } /// @@ -66,10 +62,4 @@ public RelationalCommandBuilderDependencies( /// The logging options. /// public ILoggingOptions LoggingOptions { get; init; } - - /// - /// The source for s to use. - /// - [Obsolete("RelationalCommandBuilder doesn't need TypeMappingSource. Derived class should inject the service if needed.")] - public IRelationalTypeMappingSource TypeMappingSource { get; init; } } diff --git a/src/EFCore.Relational/Storage/RelationalCommandBuilderExtensions.cs b/src/EFCore.Relational/Storage/RelationalCommandBuilderExtensions.cs index ff13faf5f7a..538051303ed 100644 --- a/src/EFCore.Relational/Storage/RelationalCommandBuilderExtensions.cs +++ b/src/EFCore.Relational/Storage/RelationalCommandBuilderExtensions.cs @@ -96,26 +96,6 @@ public static IRelationalCommandBuilder AppendLines( public static IDisposable Indent(this IRelationalCommandBuilder commandBuilder) => new Indenter(commandBuilder); - /// - /// Adds a parameter. - /// - /// The command builder. - /// - /// The key that identifies this parameter. Note that just represents a - /// placeholder for a parameter and not the actual value. This is because the same command can be - /// reused multiple times with different parameter values. - /// - /// - /// The name to be used for the parameter when the command is executed against the database. - /// - /// The same builder instance so that multiple calls can be chained. - [Obsolete("Use overload which takes TypeMapping argument.")] - public static IRelationalCommandBuilder AddParameter( - this IRelationalCommandBuilder commandBuilder, - string invariantName, - string name) - => throw new InvalidOperationException("Use overload which takes TypeMapping argument."); - /// /// Adds a parameter. /// diff --git a/src/EFCore.Relational/Storage/ValueConversion/RelationalConverterMappingHints.cs b/src/EFCore.Relational/Storage/ValueConversion/RelationalConverterMappingHints.cs index cd53cc19e4e..c774e293e72 100644 --- a/src/EFCore.Relational/Storage/ValueConversion/RelationalConverterMappingHints.cs +++ b/src/EFCore.Relational/Storage/ValueConversion/RelationalConverterMappingHints.cs @@ -22,7 +22,6 @@ public class RelationalConverterMappingHints : ConverterMappingHints /// The suggested scale of the mapped data type. /// Whether or not the mapped data type should support Unicode. /// Whether or not the mapped data type is fixed length. - /// An optional factory for creating a specific . /// The suggested . public RelationalConverterMappingHints( int? size = null, @@ -30,35 +29,13 @@ public RelationalConverterMappingHints( int? scale = null, bool? unicode = null, bool? fixedLength = null, - Func? valueGeneratorFactory = null, DbType? dbType = null) - : base(size, precision, scale, unicode, valueGeneratorFactory) + : base(size, precision, scale, unicode) { IsFixedLength = fixedLength; DbType = dbType; } - /// - /// Creates a new instance. Any hint contained in the instance - /// can be to indicate it has not been specified. - /// - /// The suggested size of the mapped data type. - /// The suggested precision of the mapped data type. - /// The suggested scale of the mapped data type. - /// Whether or not the mapped data type should support Unicode. - /// Whether or not the mapped data type is fixed length. - /// An optional factory for creating a specific . - [Obsolete("Use the overload with more parameters.")] - public RelationalConverterMappingHints( - int? size, - int? precision, - int? scale, - bool? unicode, - bool? fixedLength, - Func? valueGeneratorFactory) - : base(size, precision, scale, unicode, valueGeneratorFactory) - => IsFixedLength = fixedLength; - /// public override ConverterMappingHints With(ConverterMappingHints? hints) => hints == null @@ -69,9 +46,6 @@ public override ConverterMappingHints With(ConverterMappingHints? hints) hints.Scale ?? Scale, hints.IsUnicode ?? IsUnicode, (hints as RelationalConverterMappingHints)?.IsFixedLength ?? IsFixedLength, -#pragma warning disable CS0612 // Type or member is obsolete - hints.ValueGeneratorFactory ?? ValueGeneratorFactory, -#pragma warning restore CS0612 // Type or member is obsolete (hints as RelationalConverterMappingHints)?.DbType ?? DbType); /// @@ -84,9 +58,6 @@ public override ConverterMappingHints OverrideWith(ConverterMappingHints? hints) Scale ?? hints.Scale, IsUnicode ?? hints.IsUnicode, IsFixedLength ?? (hints as RelationalConverterMappingHints)?.IsFixedLength, -#pragma warning disable CS0612 // Type or member is obsolete - ValueGeneratorFactory ?? hints.ValueGeneratorFactory, -#pragma warning restore CS0612 // Type or member is obsolete DbType ?? (hints as RelationalConverterMappingHints)?.DbType); /// diff --git a/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs b/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs index 10f632be330..6a7713f503d 100644 --- a/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs +++ b/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs @@ -45,11 +45,12 @@ private static readonly MethodInfo ModelHasAnnotationMethodInfo private static readonly MethodInfo EntityTypeToTableMethodInfo = typeof(RelationalEntityTypeBuilderExtensions).GetRuntimeMethod( - nameof(RelationalEntityTypeBuilderExtensions.ToTable), [typeof(EntityTypeBuilder), typeof(string)])!; + nameof(RelationalEntityTypeBuilderExtensions.ToTable), + [typeof(EntityTypeBuilder), typeof(string), typeof(Action)])!; - private static readonly MethodInfo EntityTypeIsMemoryOptimizedMethodInfo - = typeof(SqlServerEntityTypeBuilderExtensions).GetRuntimeMethod( - nameof(SqlServerEntityTypeBuilderExtensions.IsMemoryOptimized), [typeof(EntityTypeBuilder), typeof(bool)])!; + private static readonly MethodInfo TableIsMemoryOptimizedMethodInfo + = typeof(SqlServerTableBuilderExtensions).GetRuntimeMethod( + nameof(SqlServerTableBuilderExtensions.IsMemoryOptimized), [typeof(TableBuilder), typeof(bool)])!; private static readonly MethodInfo PropertyIsSparseMethodInfo = typeof(SqlServerPropertyBuilderExtensions).GetRuntimeMethod( @@ -320,10 +321,15 @@ public override IReadOnlyList GenerateFluentApiCalls( if (GetAndRemove(annotations, SqlServerAnnotationNames.MemoryOptimized) is { } isMemoryOptimized) { + // ToTable(tb => tb.IsMemoryOptimized()) fragments.Add( - isMemoryOptimized - ? new MethodCallCodeFragment(EntityTypeIsMemoryOptimizedMethodInfo) - : new MethodCallCodeFragment(EntityTypeIsMemoryOptimizedMethodInfo, false)); + new MethodCallCodeFragment( + EntityTypeToTableMethodInfo, + new NestedClosureCodeFragment( + "tb", + isMemoryOptimized + ? new MethodCallCodeFragment(TableIsMemoryOptimizedMethodInfo) + : new MethodCallCodeFragment(TableIsMemoryOptimizedMethodInfo, false)))); } if (annotations.TryGetValue(SqlServerAnnotationNames.IsTemporal, out var isTemporalAnnotation) diff --git a/src/EFCore.SqlServer/Diagnostics/SqlServerEventId.cs b/src/EFCore.SqlServer/Diagnostics/SqlServerEventId.cs index bd905528320..4f02036c739 100644 --- a/src/EFCore.SqlServer/Diagnostics/SqlServerEventId.cs +++ b/src/EFCore.SqlServer/Diagnostics/SqlServerEventId.cs @@ -28,49 +28,49 @@ private enum Id // All events // Don't insert or delete anything in the middle of this section! DecimalTypeDefaultWarning = CoreEventId.ProviderBaseId, - ByteIdentityColumnWarning, - ConflictingValueGenerationStrategiesWarning, - DecimalTypeKeyWarning, - SavepointsDisabledBecauseOfMARS, - JsonTypeExperimental, // No longer used - VectorSearchWithoutApproximateWarning, + ByteIdentityColumnWarning = CoreEventId.ProviderBaseId + 1, + ConflictingValueGenerationStrategiesWarning = CoreEventId.ProviderBaseId + 2, + DecimalTypeKeyWarning = CoreEventId.ProviderBaseId + 3, + SavepointsDisabledBecauseOfMARS = CoreEventId.ProviderBaseId + 4, + JsonTypeExperimental = CoreEventId.ProviderBaseId + 5, // No longer used + VectorSearchWithoutApproximateWarning = CoreEventId.ProviderBaseId + 6, // Scaffolding events ColumnFound = CoreEventId.ProviderDesignBaseId, - ColumnNotNamedWarning, - ColumnSkipped, - DefaultSchemaFound, - ForeignKeyColumnFound, - ForeignKeyColumnMissingWarning, - ForeignKeyColumnNotNamedWarning, - ForeignKeyColumnsNotMappedWarning, - ForeignKeyNotNamedWarning, - ForeignKeyReferencesMissingPrincipalTableWarning, - IndexColumnFound, - IndexColumnNotNamedWarning, - IndexColumnSkipped, - IndexColumnsNotMappedWarning, - IndexNotNamedWarning, - IndexTableMissingWarning, - MissingSchemaWarning, - MissingTableWarning, - SequenceFound, - SequenceNotNamedWarning, - TableFound, - TableSkipped, - TypeAliasFound, - ForeignKeyTableMissingWarning, - PrimaryKeyFound, - UniqueConstraintFound, - IndexFound, - ForeignKeyFound, - ForeignKeyPrincipalColumnMissingWarning, - ReflexiveConstraintIgnored, - DuplicateForeignKeyConstraintIgnored, - ColumnWithoutTypeWarning, - ForeignKeyReferencesUnknownPrincipalTableWarning, - MissingViewDefinitionRightsWarning, - DataverseForeignKeyInvalidWarning, + ColumnNotNamedWarning = CoreEventId.ProviderDesignBaseId + 1, + ColumnSkipped = CoreEventId.ProviderDesignBaseId + 2, + DefaultSchemaFound = CoreEventId.ProviderDesignBaseId + 3, + ForeignKeyColumnFound = CoreEventId.ProviderDesignBaseId + 4, + ForeignKeyColumnMissingWarning = CoreEventId.ProviderDesignBaseId + 5, + ForeignKeyColumnNotNamedWarning = CoreEventId.ProviderDesignBaseId + 6, + ForeignKeyColumnsNotMappedWarning = CoreEventId.ProviderDesignBaseId + 7, + ForeignKeyNotNamedWarning = CoreEventId.ProviderDesignBaseId + 8, + ForeignKeyReferencesMissingPrincipalTableWarning = CoreEventId.ProviderDesignBaseId + 9, + IndexColumnFound = CoreEventId.ProviderDesignBaseId + 10, + IndexColumnNotNamedWarning = CoreEventId.ProviderDesignBaseId + 11, + IndexColumnSkipped = CoreEventId.ProviderDesignBaseId + 12, + IndexColumnsNotMappedWarning = CoreEventId.ProviderDesignBaseId + 13, + IndexNotNamedWarning = CoreEventId.ProviderDesignBaseId + 14, + IndexTableMissingWarning = CoreEventId.ProviderDesignBaseId + 15, + MissingSchemaWarning = CoreEventId.ProviderDesignBaseId + 16, + MissingTableWarning = CoreEventId.ProviderDesignBaseId + 17, + SequenceFound = CoreEventId.ProviderDesignBaseId + 18, + SequenceNotNamedWarning = CoreEventId.ProviderDesignBaseId + 19, + TableFound = CoreEventId.ProviderDesignBaseId + 20, + TableSkipped = CoreEventId.ProviderDesignBaseId + 21, + TypeAliasFound = CoreEventId.ProviderDesignBaseId + 22, + ForeignKeyTableMissingWarning = CoreEventId.ProviderDesignBaseId + 23, + PrimaryKeyFound = CoreEventId.ProviderDesignBaseId + 24, + UniqueConstraintFound = CoreEventId.ProviderDesignBaseId + 25, + IndexFound = CoreEventId.ProviderDesignBaseId + 26, + ForeignKeyFound = CoreEventId.ProviderDesignBaseId + 27, + ForeignKeyPrincipalColumnMissingWarning = CoreEventId.ProviderDesignBaseId + 28, + ReflexiveConstraintIgnored = CoreEventId.ProviderDesignBaseId + 29, + DuplicateForeignKeyConstraintIgnored = CoreEventId.ProviderDesignBaseId + 30, + ColumnWithoutTypeWarning = CoreEventId.ProviderDesignBaseId + 31, + ForeignKeyReferencesUnknownPrincipalTableWarning = CoreEventId.ProviderDesignBaseId + 32, + MissingViewDefinitionRightsWarning = CoreEventId.ProviderDesignBaseId + 33, + DataverseForeignKeyInvalidWarning = CoreEventId.ProviderDesignBaseId + 34, } private static readonly string ValidationPrefix = DbLoggerCategory.Model.Validation.Name + "."; diff --git a/src/EFCore.SqlServer/EFCore.SqlServer.baseline.json b/src/EFCore.SqlServer/EFCore.SqlServer.baseline.json index 0d47a856daa..8de92252d64 100644 --- a/src/EFCore.SqlServer/EFCore.SqlServer.baseline.json +++ b/src/EFCore.SqlServer/EFCore.SqlServer.baseline.json @@ -434,10 +434,6 @@ { "Member": "virtual Microsoft.EntityFrameworkCore.Infrastructure.SqlServerDbContextOptionsBuilder EnableRetryOnFailure(int maxRetryCount, System.TimeSpan maxRetryDelay, System.Collections.Generic.IEnumerable? errorNumbersToAdd);" }, - { - "Member": "virtual Microsoft.EntityFrameworkCore.Infrastructure.SqlServerDbContextOptionsBuilder UseAzureSqlDefaults(bool enable = true);", - "Stage": "Obsolete" - }, { "Member": "virtual Microsoft.EntityFrameworkCore.Infrastructure.SqlServerDbContextOptionsBuilder UseCompatibilityLevel(int compatibilityLevel);" } diff --git a/src/EFCore.SqlServer/Extensions/SqlServerEntityTypeBuilderExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerEntityTypeBuilderExtensions.cs index 39e115cd27c..9f68845f04d 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerEntityTypeBuilderExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerEntityTypeBuilderExtensions.cs @@ -18,6 +18,9 @@ namespace Microsoft.EntityFrameworkCore; /// public static class SqlServerEntityTypeBuilderExtensions { + // DO NOT REMOVE, IN GENERATED CODE + #region IsMemoryOptimized (obsolete, kept for existing migration snapshots) + /// /// Configures the table that the entity maps to when targeting SQL Server as memory-optimized. /// @@ -97,6 +100,8 @@ public static OwnedNavigationBuilder IsMemoryOptimized< => (OwnedNavigationBuilder)IsMemoryOptimized( (OwnedNavigationBuilder)collectionOwnershipBuilder, memoryOptimized); + #endregion + /// /// Configures the table that the entity maps to when targeting SQL Server as memory-optimized. /// diff --git a/src/EFCore.SqlServer/Infrastructure/SqlServerDbContextOptionsBuilder.cs b/src/EFCore.SqlServer/Infrastructure/SqlServerDbContextOptionsBuilder.cs index ab8d5649ca8..bb8b3554d26 100644 --- a/src/EFCore.SqlServer/Infrastructure/SqlServerDbContextOptionsBuilder.cs +++ b/src/EFCore.SqlServer/Infrastructure/SqlServerDbContextOptionsBuilder.cs @@ -118,11 +118,4 @@ public virtual SqlServerDbContextOptionsBuilder EnableRetryOnFailure( public virtual SqlServerDbContextOptionsBuilder UseCompatibilityLevel(int compatibilityLevel) => WithOption(e => e.WithSqlServerCompatibilityLevel(compatibilityLevel)); - /// - /// Configures the context to use defaults optimized for Azure SQL, including retries on errors. - /// - /// Whether the defaults should be enabled. - [Obsolete("Use UseAzureSql instead of UseSqlServer with UseAzureSqlDefaults.")] - public virtual SqlServerDbContextOptionsBuilder UseAzureSqlDefaults(bool enable = true) - => WithOption(e => e.WithLegacyAzureSql(enable)); } diff --git a/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerValueGeneratorSelector.cs b/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerValueGeneratorSelector.cs index e6dac7ad70a..a64534c3d99 100644 --- a/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerValueGeneratorSelector.cs +++ b/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerValueGeneratorSelector.cs @@ -47,24 +47,6 @@ public SqlServerValueGeneratorSelector( public new virtual ISqlServerValueGeneratorCache Cache => (ISqlServerValueGeneratorCache)base.Cache; - /// - /// 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. - /// - [Obsolete("Use TrySelect and throw if needed when the generator is not found.")] - public override ValueGenerator? Select(IProperty property, ITypeBase typeBase) - { - if (TrySelect(property, typeBase, out var valueGenerator)) - { - return valueGenerator; - } - - throw new NotSupportedException( - CoreStrings.NoValueGenerator(property.Name, property.DeclaringType.DisplayName(), property.ClrType.ShortDisplayName())); - } - /// /// 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 diff --git a/src/EFCore.Sqlite.Core/Diagnostics/SqliteEventId.cs b/src/EFCore.Sqlite.Core/Diagnostics/SqliteEventId.cs index 477ede53c99..05d0c1fa4f0 100644 --- a/src/EFCore.Sqlite.Core/Diagnostics/SqliteEventId.cs +++ b/src/EFCore.Sqlite.Core/Diagnostics/SqliteEventId.cs @@ -28,9 +28,9 @@ private enum Id { // Model validation events SchemaConfiguredWarning = CoreEventId.ProviderBaseId, - SequenceConfiguredWarning, - CompositeKeyWithValueGeneration, - ConflictingValueGenerationStrategiesWarning, + SequenceConfiguredWarning = CoreEventId.ProviderBaseId + 1, + CompositeKeyWithValueGeneration = CoreEventId.ProviderBaseId + 2, + ConflictingValueGenerationStrategiesWarning = CoreEventId.ProviderBaseId + 3, // Infrastructure events UnexpectedConnectionTypeWarning = CoreEventId.ProviderBaseId + 100, @@ -40,18 +40,18 @@ private enum Id // Scaffolding events ColumnFound = CoreEventId.ProviderDesignBaseId, - ForeignKeyFound, - ForeignKeyPrincipalColumnMissingWarning, - ForeignKeyReferencesMissingTableWarning, - IndexFound, - MissingTableWarning, - PrimaryKeyFound, - SchemasNotSupportedWarning, - TableFound, - UniqueConstraintFound, - InferringTypes, - OutOfRangeWarning, - FormatWarning + ForeignKeyFound = CoreEventId.ProviderDesignBaseId + 1, + ForeignKeyPrincipalColumnMissingWarning = CoreEventId.ProviderDesignBaseId + 2, + ForeignKeyReferencesMissingTableWarning = CoreEventId.ProviderDesignBaseId + 3, + IndexFound = CoreEventId.ProviderDesignBaseId + 4, + MissingTableWarning = CoreEventId.ProviderDesignBaseId + 5, + PrimaryKeyFound = CoreEventId.ProviderDesignBaseId + 6, + SchemasNotSupportedWarning = CoreEventId.ProviderDesignBaseId + 7, + TableFound = CoreEventId.ProviderDesignBaseId + 8, + UniqueConstraintFound = CoreEventId.ProviderDesignBaseId + 9, + InferringTypes = CoreEventId.ProviderDesignBaseId + 10, + OutOfRangeWarning = CoreEventId.ProviderDesignBaseId + 11, + FormatWarning = CoreEventId.ProviderDesignBaseId + 12 } private static readonly string ValidationPrefix = DbLoggerCategory.Model.Validation.Name + "."; diff --git a/src/EFCore/Diagnostics/CoreEventId.cs b/src/EFCore/Diagnostics/CoreEventId.cs index c7f4b9a901c..62a2cad329b 100644 --- a/src/EFCore/Diagnostics/CoreEventId.cs +++ b/src/EFCore/Diagnostics/CoreEventId.cs @@ -50,97 +50,97 @@ private enum Id { // Update events SaveChangesFailed = CoreBaseId, - DuplicateDependentEntityTypeInstanceWarning, - CascadeDelete, - CascadeDeleteOrphan, - SaveChangesStarting, - SaveChangesCompleted, - OptimisticConcurrencyException, - SaveChangesCanceled, + DuplicateDependentEntityTypeInstanceWarning = CoreBaseId + 1, + CascadeDelete = CoreBaseId + 2, + CascadeDeleteOrphan = CoreBaseId + 3, + SaveChangesStarting = CoreBaseId + 4, + SaveChangesCompleted = CoreBaseId + 5, + OptimisticConcurrencyException = CoreBaseId + 6, + SaveChangesCanceled = CoreBaseId + 7, // Query events QueryIterationFailed = CoreBaseId + 100, - Obsolete_QueryModelCompiling, - RowLimitingOperationWithoutOrderByWarning, - FirstWithoutOrderByAndFilterWarning, - Obsolete_QueryModelOptimized, - Obsolete_NavigationIncluded, - Obsolete_IncludeIgnoredWarning, - QueryExecutionPlanned, - PossibleUnintendedCollectionNavigationNullComparisonWarning, - PossibleUnintendedReferenceComparisonWarning, - InvalidIncludePathError, - QueryCompilationStarting, - NavigationBaseIncluded, - NavigationBaseIncludeIgnored, - DistinctAfterOrderByWithoutRowLimitingOperatorWarning, - QueryCanceled, - StringEnumValueInJson, + Obsolete_QueryModelCompiling = CoreBaseId + 101, + RowLimitingOperationWithoutOrderByWarning = CoreBaseId + 102, + FirstWithoutOrderByAndFilterWarning = CoreBaseId + 103, + Obsolete_QueryModelOptimized = CoreBaseId + 104, + Obsolete_NavigationIncluded = CoreBaseId + 105, + Obsolete_IncludeIgnoredWarning = CoreBaseId + 106, + QueryExecutionPlanned = CoreBaseId + 107, + PossibleUnintendedCollectionNavigationNullComparisonWarning = CoreBaseId + 108, + PossibleUnintendedReferenceComparisonWarning = CoreBaseId + 109, + InvalidIncludePathError = CoreBaseId + 110, + QueryCompilationStarting = CoreBaseId + 111, + NavigationBaseIncluded = CoreBaseId + 112, + NavigationBaseIncludeIgnored = CoreBaseId + 113, + DistinctAfterOrderByWithoutRowLimitingOperatorWarning = CoreBaseId + 114, + QueryCanceled = CoreBaseId + 115, + StringEnumValueInJson = CoreBaseId + 116, // Infrastructure events SensitiveDataLoggingEnabledWarning = CoreBaseId + 400, - ServiceProviderCreated, - ManyServiceProvidersCreatedWarning, - ContextInitialized, - ExecutionStrategyRetrying, - LazyLoadOnDisposedContextWarning, - NavigationLazyLoading, - ContextDisposed, - DetachedLazyLoadingWarning, - ServiceProviderDebugInfo, - RedundantAddServicesCallWarning, - OldModelVersionWarning, - CompiledModelProviderMismatchWarning, + ServiceProviderCreated = CoreBaseId + 401, + ManyServiceProvidersCreatedWarning = CoreBaseId + 402, + ContextInitialized = CoreBaseId + 403, + ExecutionStrategyRetrying = CoreBaseId + 404, + LazyLoadOnDisposedContextWarning = CoreBaseId + 405, + NavigationLazyLoading = CoreBaseId + 406, + ContextDisposed = CoreBaseId + 407, + DetachedLazyLoadingWarning = CoreBaseId + 408, + ServiceProviderDebugInfo = CoreBaseId + 409, + RedundantAddServicesCallWarning = CoreBaseId + 410, + OldModelVersionWarning = CoreBaseId + 411, + CompiledModelProviderMismatchWarning = CoreBaseId + 412, // Model and ModelValidation events ShadowPropertyCreated = CoreBaseId + 600, - RedundantIndexRemoved, - IncompatibleMatchingForeignKeyProperties, - Obsolete_RequiredAttributeOnDependent, - Obsolete_RequiredAttributeOnBothNavigations, - ConflictingShadowForeignKeysWarning, - MultiplePrimaryKeyCandidates, - MultipleNavigationProperties, - MultipleInversePropertiesSameTargetWarning, - Obsolete_NonDefiningInverseNavigationWarning, - NonOwnershipInverseNavigationWarning, - ForeignKeyAttributesOnBothPropertiesWarning, - ForeignKeyAttributesOnBothNavigationsWarning, - ConflictingForeignKeyAttributesOnNavigationAndPropertyWarning, - RedundantForeignKeyWarning, - Obsolete_NonNullableInverted, - Obsolete_NonNullableReferenceOnBothNavigations, - Obsolete_NonNullableReferenceOnDependent, - Obsolete_RequiredAttributeInverted, - RequiredAttributeOnCollection, - CollectionWithoutComparer, - ConflictingKeylessAndKeyAttributesWarning, - PossibleIncorrectRequiredNavigationWithQueryFilterInteractionWarning, - RequiredAttributeOnSkipNavigation, - AmbiguousEndRequiredWarning, - ShadowForeignKeyPropertyCreated, - MappedEntityTypeIgnoredWarning, - MappedNavigationIgnoredWarning, - MappedPropertyIgnoredWarning, - MappedComplexPropertyIgnoredWarning, - TypeLoadingErrorWarning, - SkippedEntityTypeConfigurationWarning, - NoEntityTypeConfigurationsWarning, - AccidentalEntityType, - AccidentalComplexPropertyCollection, + RedundantIndexRemoved = CoreBaseId + 601, + IncompatibleMatchingForeignKeyProperties = CoreBaseId + 602, + Obsolete_RequiredAttributeOnDependent = CoreBaseId + 603, + Obsolete_RequiredAttributeOnBothNavigations = CoreBaseId + 604, + ConflictingShadowForeignKeysWarning = CoreBaseId + 605, + MultiplePrimaryKeyCandidates = CoreBaseId + 606, + MultipleNavigationProperties = CoreBaseId + 607, + MultipleInversePropertiesSameTargetWarning = CoreBaseId + 608, + Obsolete_NonDefiningInverseNavigationWarning = CoreBaseId + 609, + NonOwnershipInverseNavigationWarning = CoreBaseId + 610, + ForeignKeyAttributesOnBothPropertiesWarning = CoreBaseId + 611, + ForeignKeyAttributesOnBothNavigationsWarning = CoreBaseId + 612, + ConflictingForeignKeyAttributesOnNavigationAndPropertyWarning = CoreBaseId + 613, + RedundantForeignKeyWarning = CoreBaseId + 614, + Obsolete_NonNullableInverted = CoreBaseId + 615, + Obsolete_NonNullableReferenceOnBothNavigations = CoreBaseId + 616, + Obsolete_NonNullableReferenceOnDependent = CoreBaseId + 617, + Obsolete_RequiredAttributeInverted = CoreBaseId + 618, + RequiredAttributeOnCollection = CoreBaseId + 619, + CollectionWithoutComparer = CoreBaseId + 620, + ConflictingKeylessAndKeyAttributesWarning = CoreBaseId + 621, + PossibleIncorrectRequiredNavigationWithQueryFilterInteractionWarning = CoreBaseId + 622, + RequiredAttributeOnSkipNavigation = CoreBaseId + 623, + AmbiguousEndRequiredWarning = CoreBaseId + 624, + ShadowForeignKeyPropertyCreated = CoreBaseId + 625, + MappedEntityTypeIgnoredWarning = CoreBaseId + 626, + MappedNavigationIgnoredWarning = CoreBaseId + 627, + MappedPropertyIgnoredWarning = CoreBaseId + 628, + MappedComplexPropertyIgnoredWarning = CoreBaseId + 629, + TypeLoadingErrorWarning = CoreBaseId + 630, + SkippedEntityTypeConfigurationWarning = CoreBaseId + 631, + NoEntityTypeConfigurationsWarning = CoreBaseId + 632, + AccidentalEntityType = CoreBaseId + 633, + AccidentalComplexPropertyCollection = CoreBaseId + 634, // ChangeTracking events DetectChangesStarting = CoreBaseId + 800, - DetectChangesCompleted, - PropertyChangeDetected, - ForeignKeyChangeDetected, - CollectionChangeDetected, - ReferenceChangeDetected, - StartedTracking, - StateChanged, - ValueGenerated, - SkipCollectionChangeDetected, - ComplexElementPropertyChangeDetected + DetectChangesCompleted = CoreBaseId + 801, + PropertyChangeDetected = CoreBaseId + 802, + ForeignKeyChangeDetected = CoreBaseId + 803, + CollectionChangeDetected = CoreBaseId + 804, + ReferenceChangeDetected = CoreBaseId + 805, + StartedTracking = CoreBaseId + 806, + StateChanged = CoreBaseId + 807, + ValueGenerated = CoreBaseId + 808, + SkipCollectionChangeDetected = CoreBaseId + 809, + ComplexElementPropertyChangeDetected = CoreBaseId + 810 } private static readonly string _updatePrefix = DbLoggerCategory.Update.Name + "."; @@ -818,21 +818,6 @@ private static EventId MakeModelValidationId(Id id) public static readonly EventId MultipleInversePropertiesSameTargetWarning = MakeModelId(Id.MultipleInversePropertiesSameTargetWarning); - /// - /// The navigation that points to is not the defining navigation. - /// - /// - /// - /// This event is in the category. - /// - /// - /// This event uses the payload when used with a - /// . - /// - /// - [Obsolete("Log message with this event Id has been removed.")] - public static readonly EventId NonDefiningInverseNavigationWarning = MakeModelId(Id.Obsolete_NonDefiningInverseNavigationWarning); - /// /// The navigation that points to is not the defining navigation. /// diff --git a/src/EFCore/EFCore.baseline.json b/src/EFCore/EFCore.baseline.json index 24e1fc07293..792bfa1e922 100644 --- a/src/EFCore/EFCore.baseline.json +++ b/src/EFCore/EFCore.baseline.json @@ -199,10 +199,6 @@ }, { "Member": "virtual Microsoft.EntityFrameworkCore.Infrastructure.AnnotatableBuilder MergeAnnotationsFrom(TMetadata annotatable, Microsoft.EntityFrameworkCore.Metadata.ConfigurationSource minimalConfigurationSource);" - }, - { - "Member": "virtual Microsoft.EntityFrameworkCore.Infrastructure.AnnotatableBuilder? RemoveAnnotation(string name, Microsoft.EntityFrameworkCore.Metadata.ConfigurationSource configurationSource);", - "Stage": "Obsolete" } ], "Properties": [ @@ -2846,7 +2842,7 @@ "Type": "class Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints", "Methods": [ { - "Member": "ConverterMappingHints(int? size = null, int? precision = null, int? scale = null, bool? unicode = null, System.Func? valueGeneratorFactory = null);" + "Member": "ConverterMappingHints(int? size = null, int? precision = null, int? scale = null, bool? unicode = null);" }, { "Member": "virtual Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints OverrideWith(Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints? hints);" @@ -2867,10 +2863,6 @@ }, { "Member": "virtual int? Size { get; }" - }, - { - "Member": "virtual System.Func? ValueGeneratorFactory { get; }", - "Stage": "Obsolete" } ] }, @@ -2998,10 +2990,6 @@ { "Member": "static readonly Microsoft.Extensions.Logging.EventId NoEntityTypeConfigurationsWarning" }, - { - "Member": "static readonly Microsoft.Extensions.Logging.EventId NonDefiningInverseNavigationWarning", - "Stage": "Obsolete" - }, { "Member": "static readonly Microsoft.Extensions.Logging.EventId NonOwnershipInverseNavigationWarning" }, @@ -4954,10 +4942,6 @@ }, { "Member": "virtual Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer ProviderValueComparer { get; }" - }, - { - "Member": "virtual System.Func? ValueGeneratorFactory { get; }", - "Stage": "Obsolete" } ] }, @@ -5144,10 +5128,6 @@ { "Member": "virtual Microsoft.EntityFrameworkCore.AutoTransactionBehavior AutoTransactionBehavior { get; set; }" }, - { - "Member": "virtual bool AutoTransactionsEnabled { get; set; }", - "Stage": "Obsolete" - }, { "Member": "virtual Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction? CurrentTransaction { get; }" }, @@ -9695,14 +9675,6 @@ }, { "Member": "void GetBindings(Microsoft.EntityFrameworkCore.Metadata.IReadOnlyComplexType complexType, out Microsoft.EntityFrameworkCore.Metadata.InstantiationBinding constructorBinding, out Microsoft.EntityFrameworkCore.Metadata.InstantiationBinding? serviceOnlyBinding);" - }, - { - "Member": "bool TryBindConstructor(Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType entityType, System.Reflection.ConstructorInfo constructor, out Microsoft.EntityFrameworkCore.Metadata.InstantiationBinding? binding, out System.Collections.Generic.IEnumerable? unboundParameters);", - "Stage": "Obsolete" - }, - { - "Member": "bool TryBindConstructor(Microsoft.EntityFrameworkCore.Metadata.IMutableEntityType entityType, System.Reflection.ConstructorInfo constructor, out Microsoft.EntityFrameworkCore.Metadata.InstantiationBinding? binding, out System.Collections.Generic.IEnumerable? unboundParameters);", - "Stage": "Obsolete" } ] }, @@ -10983,14 +10955,6 @@ { "Member": "Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType? AddEntityType(string name, System.Type clrType, bool fromDataAnnotation = false);" }, - { - "Member": "Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType? AddEntityType(string name, string definingNavigationName, Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType definingEntityType, bool fromDataAnnotation = false);", - "Stage": "Obsolete" - }, - { - "Member": "Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType? AddEntityType(System.Type type, string definingNavigationName, Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType definingEntityType, bool fromDataAnnotation = false);", - "Stage": "Obsolete" - }, { "Member": "string? AddIgnored(string typeName, bool fromDataAnnotation = false);" }, @@ -11447,10 +11411,6 @@ "Properties": [ { "Member": "Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionPropertyBuilder Builder { get; }" - }, - { - "Member": "Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType DeclaringEntityType { get; }", - "Stage": "Obsolete" } ] }, @@ -14240,10 +14200,6 @@ } ], "Properties": [ - { - "Member": "Microsoft.EntityFrameworkCore.Metadata.IMutableEntityType DeclaringEntityType { get; }", - "Stage": "Obsolete" - }, { "Member": "bool IsAutoLoaded { get; set; }" }, @@ -15080,12 +15036,6 @@ { "Member": "Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer GetValueComparer();" } - ], - "Properties": [ - { - "Member": "Microsoft.EntityFrameworkCore.Metadata.IEntityType DeclaringEntityType { get; }", - "Stage": "Obsolete" - } ] }, { @@ -15533,10 +15483,6 @@ { "Member": "System.Collections.Generic.IEnumerable GetNavigations();" }, - { - "Member": "System.Linq.Expressions.LambdaExpression? GetQueryFilter();", - "Stage": "Obsolete" - }, { "Member": "System.Collections.Generic.IEnumerable GetReferencingForeignKeys();" }, @@ -15866,10 +15812,6 @@ } ], "Properties": [ - { - "Member": "Microsoft.EntityFrameworkCore.Metadata.IReadOnlyEntityType DeclaringEntityType { get; }", - "Stage": "Obsolete" - }, { "Member": "bool IsAutoLoaded { get; }" }, @@ -16467,10 +16409,6 @@ { "Member": "Microsoft.EntityFrameworkCore.Storage.CoreTypeMapping? FindMapping(Microsoft.EntityFrameworkCore.Metadata.IElementType elementType);" }, - { - "Member": "Microsoft.EntityFrameworkCore.Storage.CoreTypeMapping? FindMapping(System.Reflection.MemberInfo member);", - "Stage": "Obsolete" - }, { "Member": "Microsoft.EntityFrameworkCore.Storage.CoreTypeMapping? FindMapping(System.Reflection.MemberInfo member, Microsoft.EntityFrameworkCore.Metadata.IModel model, bool useAttributes);" }, @@ -16639,10 +16577,6 @@ { "Type": "interface Microsoft.EntityFrameworkCore.ValueGeneration.IValueGeneratorSelector", "Methods": [ - { - "Member": "Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator? Select(Microsoft.EntityFrameworkCore.Metadata.IProperty property, Microsoft.EntityFrameworkCore.Metadata.ITypeBase typeBase);", - "Stage": "Obsolete" - }, { "Member": "bool TrySelect(Microsoft.EntityFrameworkCore.Metadata.IProperty property, Microsoft.EntityFrameworkCore.Metadata.ITypeBase typeBase, out Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator? valueGenerator);" } @@ -19803,14 +19737,6 @@ { "Member": "ParameterQueryRootExpression(System.Type elementType, Microsoft.EntityFrameworkCore.Query.QueryParameterExpression queryParameterExpression);" }, - { - "Member": "ParameterQueryRootExpression(Microsoft.EntityFrameworkCore.Query.IAsyncQueryProvider asyncQueryProvider, System.Type elementType, System.Linq.Expressions.ParameterExpression parameterExpression);", - "Stage": "Obsolete" - }, - { - "Member": "ParameterQueryRootExpression(System.Type elementType, System.Linq.Expressions.ParameterExpression parameterExpression);", - "Stage": "Obsolete" - }, { "Member": "override System.Linq.Expressions.Expression DetachQueryProvider();" }, @@ -19822,10 +19748,6 @@ } ], "Properties": [ - { - "Member": "virtual System.Linq.Expressions.ParameterExpression ParameterExpression { get; }", - "Stage": "Obsolete" - }, { "Member": "virtual Microsoft.EntityFrameworkCore.Query.QueryParameterExpression QueryParameterExpression { get; }" } @@ -22577,10 +22499,6 @@ }, { "Member": "virtual Microsoft.EntityFrameworkCore.Metadata.RuntimeEntityType GetOrAddAdHocEntityType(Microsoft.EntityFrameworkCore.Metadata.RuntimeEntityType entityType);" - }, - { - "Member": "virtual void SetSkipDetectChanges(bool skipDetectChanges);", - "Stage": "Obsolete" } ] }, @@ -25085,17 +25003,9 @@ { "Member": "ValueGeneratorSelector(Microsoft.EntityFrameworkCore.ValueGeneration.ValueGeneratorSelectorDependencies dependencies);" }, - { - "Member": "virtual Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator Create(Microsoft.EntityFrameworkCore.Metadata.IProperty property, Microsoft.EntityFrameworkCore.Metadata.ITypeBase typeBase);", - "Stage": "Obsolete" - }, { "Member": "virtual Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator? FindForType(Microsoft.EntityFrameworkCore.Metadata.IProperty property, Microsoft.EntityFrameworkCore.Metadata.ITypeBase typeBase, System.Type clrType);" }, - { - "Member": "virtual Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator? Select(Microsoft.EntityFrameworkCore.Metadata.IProperty property, Microsoft.EntityFrameworkCore.Metadata.ITypeBase typeBase);", - "Stage": "Obsolete" - }, { "Member": "virtual bool TryCreate(Microsoft.EntityFrameworkCore.Metadata.IProperty property, Microsoft.EntityFrameworkCore.Metadata.ITypeBase typeBase, out Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator? valueGenerator);" }, diff --git a/src/EFCore/Infrastructure/AnnotatableBuilder.cs b/src/EFCore/Infrastructure/AnnotatableBuilder.cs index 3e8c9efdcc4..b2e74bf565e 100644 --- a/src/EFCore/Infrastructure/AnnotatableBuilder.cs +++ b/src/EFCore/Infrastructure/AnnotatableBuilder.cs @@ -137,18 +137,6 @@ private static bool CanSetAnnotationValue( || canOverrideSameSource); } - /// - /// Removes any annotation with the given name. - /// - /// The name of the annotation to remove. - /// The configuration source of the annotation to be set. - /// The same builder so that multiple calls can be chained. - [Obsolete("Use HasNoAnnotation instead")] - public virtual AnnotatableBuilder? RemoveAnnotation( - string name, - ConfigurationSource configurationSource) - => HasNoAnnotation(name, configurationSource); - /// /// Removes any annotation with the given name. /// diff --git a/src/EFCore/Infrastructure/DatabaseFacade.cs b/src/EFCore/Infrastructure/DatabaseFacade.cs index 8d33d895c6b..62792251a55 100644 --- a/src/EFCore/Infrastructure/DatabaseFacade.cs +++ b/src/EFCore/Infrastructure/DatabaseFacade.cs @@ -385,47 +385,6 @@ public virtual IExecutionStrategy CreateExecutionStrategy() public virtual IDbContextTransaction? CurrentTransaction => Dependencies.TransactionManager.CurrentTransaction; - /// - /// Gets or sets a value indicating whether a transaction will be created automatically by - /// if none of the 'BeginTransaction' or 'UseTransaction' methods have been called. - /// - /// - /// - /// Setting this value to will also disable the for - /// - /// - /// - /// The default value is , meaning that will always use a - /// transaction when saving changes. - /// - /// - /// Setting this value to should only be done with caution, since the database could be left in an - /// inconsistent state if failure occurs. - /// - /// - /// See Transactions in EF Core for more information and examples. - /// - /// - [Obsolete("Use " + nameof(AutoTransactionBehavior) + " instead")] - public virtual bool AutoTransactionsEnabled - { - get => AutoTransactionBehavior is AutoTransactionBehavior.Always or AutoTransactionBehavior.WhenNeeded; - set - { - if (value) - { - if (AutoTransactionBehavior == AutoTransactionBehavior.Never) - { - AutoTransactionBehavior = AutoTransactionBehavior.WhenNeeded; - } - } - else - { - AutoTransactionBehavior = AutoTransactionBehavior.Never; - } - } - } - /// /// Gets or sets a value indicating whether a transaction will be created automatically by /// if neither 'BeginTransaction' nor 'UseTransaction' has been called. diff --git a/src/EFCore/Metadata/IConstructorBindingFactory.cs b/src/EFCore/Metadata/IConstructorBindingFactory.cs index c4feef7f08a..576c3e899aa 100644 --- a/src/EFCore/Metadata/IConstructorBindingFactory.cs +++ b/src/EFCore/Metadata/IConstructorBindingFactory.cs @@ -68,35 +68,4 @@ void GetBindings( out InstantiationBinding constructorBinding, out InstantiationBinding? serviceOnlyBinding); - /// - /// Attempts to create a for the given entity type and - /// - /// - /// The entity type. - /// The constructor to use. - /// The binding, or if could be created. - /// The parameters that could not be bound. - /// if a binding was created; otherwise. - [Obsolete("Use GetBindings")] - bool TryBindConstructor( - IConventionEntityType entityType, - ConstructorInfo constructor, - [NotNullWhen(true)] out InstantiationBinding? binding, - [NotNullWhen(false)] out IEnumerable? unboundParameters); - - /// - /// Attempts to create a for the given entity type and - /// - /// - /// The entity type. - /// The constructor to use. - /// The binding, or if could be created. - /// The parameters that could not be bound. - /// if a binding was created; otherwise. - [Obsolete("Use GetBindings")] - bool TryBindConstructor( - IMutableEntityType entityType, - ConstructorInfo constructor, - [NotNullWhen(true)] out InstantiationBinding? binding, - [NotNullWhen(false)] out IEnumerable? unboundParameters); } diff --git a/src/EFCore/Metadata/IConventionModel.cs b/src/EFCore/Metadata/IConventionModel.cs index 837baf61964..c10a64d9a7f 100644 --- a/src/EFCore/Metadata/IConventionModel.cs +++ b/src/EFCore/Metadata/IConventionModel.cs @@ -123,36 +123,6 @@ public interface IConventionModel : IReadOnlyModel, IConventionAnnotatable [DynamicallyAccessedMembers(IEntityType.DynamicallyAccessedMemberTypes)] Type clrType, bool fromDataAnnotation = false); - /// - /// Adds an owned entity type with a defining navigation to the model. - /// - /// The name of the entity type to be added. - /// The defining navigation. - /// The defining entity type. - /// Indicates whether the configuration was specified using a data annotation. - /// The new entity type. - [Obsolete] - IConventionEntityType? AddEntityType( - string name, - string definingNavigationName, - IConventionEntityType definingEntityType, - bool fromDataAnnotation = false); - - /// - /// Adds an owned entity type with a defining navigation to the model. - /// - /// The CLR class that is used to represent instances of this entity type. - /// The defining navigation. - /// The defining entity type. - /// Indicates whether the configuration was specified using a data annotation. - /// The new entity type. - [Obsolete] - IConventionEntityType? AddEntityType( - [DynamicallyAccessedMembers(IEntityType.DynamicallyAccessedMemberTypes)] Type type, - string definingNavigationName, - IConventionEntityType definingEntityType, - bool fromDataAnnotation = false); - /// /// Adds an owned entity type of default type to the model. /// diff --git a/src/EFCore/Metadata/IConventionProperty.cs b/src/EFCore/Metadata/IConventionProperty.cs index 6c84a182213..11f8080dfe1 100644 --- a/src/EFCore/Metadata/IConventionProperty.cs +++ b/src/EFCore/Metadata/IConventionProperty.cs @@ -25,13 +25,6 @@ public interface IConventionProperty : IReadOnlyProperty, IConventionPropertyBas /// If the property has been removed from the model. new IConventionPropertyBuilder Builder { get; } - /// - /// Gets the entity type that this property belongs to. - /// - [Obsolete("Use DeclaringType and cast to IConventionEntityType or IConventionComplexType")] - new IConventionEntityType DeclaringEntityType - => (IConventionEntityType)DeclaringType; - /// /// Returns the configuration source for . /// diff --git a/src/EFCore/Metadata/IMutableProperty.cs b/src/EFCore/Metadata/IMutableProperty.cs index 44787f982c3..f6027246e8c 100644 --- a/src/EFCore/Metadata/IMutableProperty.cs +++ b/src/EFCore/Metadata/IMutableProperty.cs @@ -20,13 +20,6 @@ namespace Microsoft.EntityFrameworkCore.Metadata; /// public interface IMutableProperty : IReadOnlyProperty, IMutablePropertyBase { - /// - /// Gets the entity type that this property belongs to. - /// - [Obsolete("Use DeclaringType and cast to IMutableEntityType or IMutableComplexType")] - new IMutableEntityType DeclaringEntityType - => (IMutableEntityType)DeclaringType; - /// /// Gets or sets a value indicating whether this property can contain . /// diff --git a/src/EFCore/Metadata/IProperty.cs b/src/EFCore/Metadata/IProperty.cs index 83d5bf3fb5b..29f6bcdbb8b 100644 --- a/src/EFCore/Metadata/IProperty.cs +++ b/src/EFCore/Metadata/IProperty.cs @@ -13,13 +13,6 @@ namespace Microsoft.EntityFrameworkCore.Metadata; /// public interface IProperty : IReadOnlyProperty, IPropertyBase { - /// - /// Gets the entity type that this property belongs to. - /// - [Obsolete("Use DeclaringType and cast to IEntityType or IComplexType")] - new IEntityType DeclaringEntityType - => (IEntityType)DeclaringType; - /// /// Creates an for values of the given property type. /// diff --git a/src/EFCore/Metadata/IReadOnlyEntityType.cs b/src/EFCore/Metadata/IReadOnlyEntityType.cs index 6a0233b3d85..d376eeb9e01 100644 --- a/src/EFCore/Metadata/IReadOnlyEntityType.cs +++ b/src/EFCore/Metadata/IReadOnlyEntityType.cs @@ -35,13 +35,6 @@ public interface IReadOnlyEntityType : IReadOnlyTypeBase /// The query filters. IReadOnlyCollection GetDeclaredQueryFilters(); - /// - /// Gets the LINQ expression filter automatically applied to queries for this entity type. - /// - /// The LINQ expression filter. - [Obsolete("Use GetDeclaredQueryFilters() instead.")] - LambdaExpression? GetQueryFilter(); - /// /// Retrieves the query filter associated with the specified key. /// diff --git a/src/EFCore/Metadata/IReadOnlyProperty.cs b/src/EFCore/Metadata/IReadOnlyProperty.cs index b702054ba28..3c79c1188a0 100644 --- a/src/EFCore/Metadata/IReadOnlyProperty.cs +++ b/src/EFCore/Metadata/IReadOnlyProperty.cs @@ -15,13 +15,6 @@ namespace Microsoft.EntityFrameworkCore.Metadata; /// public interface IReadOnlyProperty : IReadOnlyPropertyBase { - /// - /// Gets the entity type that this property belongs to. - /// - [Obsolete("Use DeclaringType and cast to IReadOnlyEntityType or IReadOnlyComplexType")] - IReadOnlyEntityType DeclaringEntityType - => (IReadOnlyEntityType)DeclaringType; - /// /// Gets a value indicating whether this property can contain . /// diff --git a/src/EFCore/Metadata/Internal/ConstructorBindingFactory.cs b/src/EFCore/Metadata/Internal/ConstructorBindingFactory.cs index 0e54232dfda..781b6e9cb7e 100644 --- a/src/EFCore/Metadata/Internal/ConstructorBindingFactory.cs +++ b/src/EFCore/Metadata/Internal/ConstructorBindingFactory.cs @@ -207,44 +207,6 @@ static IEnumerable ConstructConstructor(IGrouping parameters.Key.GetParameters().Select(y => $"{y.ParameterType.ShortDisplayName()} {y.Name}"); } - /// - /// 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. - /// - public virtual bool TryBindConstructor( - IMutableEntityType entityType, - ConstructorInfo constructor, - [NotNullWhen(true)] out InstantiationBinding? binding, - [NotNullWhen(false)] out IEnumerable? unboundParameters) - => TryBindConstructor( - entityType, - constructor, - static (f, e, p, n) => f.FindParameter((IEntityType)e, p, n), - static (f, e, p, n) => f?.Bind(e, p, n), - out binding, - out unboundParameters); - - /// - /// 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. - /// - public virtual bool TryBindConstructor( - IConventionEntityType entityType, - ConstructorInfo constructor, - [NotNullWhen(true)] out InstantiationBinding? binding, - [NotNullWhen(false)] out IEnumerable? unboundParameters) - => TryBindConstructor( - entityType, - constructor, - static (f, e, p, n) => f.FindParameter((IEntityType)e, p, n), - static (f, e, p, n) => f?.Bind(e, p, n), - out binding, - out unboundParameters); - private bool TryBindConstructor( T structuralType, ConstructorInfo constructor, diff --git a/src/EFCore/Metadata/Internal/EntityType.cs b/src/EFCore/Metadata/Internal/EntityType.cs index 68d6541d5b3..6cc6fcf2bef 100644 --- a/src/EFCore/Metadata/Internal/EntityType.cs +++ b/src/EFCore/Metadata/Internal/EntityType.cs @@ -2787,16 +2787,6 @@ public virtual PropertyAccessMode GetNavigationAccessMode() public virtual IReadOnlyCollection GetDeclaredQueryFilters() => (QueryFilterCollection?)this[CoreAnnotationNames.QueryFilter] ?? new QueryFilterCollection(); - /// - /// 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. - /// - [Obsolete("Use GetDeclaredQueryFilters() instead.")] - public virtual LambdaExpression? GetQueryFilter() - => GetDeclaredQueryFilters()?.FirstOrDefault(f => f.IsAnonymous)?.Expression; - /// /// 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 diff --git a/src/EFCore/Metadata/Internal/Model.cs b/src/EFCore/Metadata/Internal/Model.cs index 2f34fcae790..dab7ec6d556 100644 --- a/src/EFCore/Metadata/Internal/Model.cs +++ b/src/EFCore/Metadata/Internal/Model.cs @@ -1594,22 +1594,6 @@ IMutableEntityType IMutableModel.AddEntityType( IMutableEntityType definingEntityType) => AddEntityType(name, definingNavigationName, (EntityType)definingEntityType, ConfigurationSource.Explicit)!; - /// - /// 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. - /// - [Obsolete, DebuggerStepThrough] // The interface didn't mark method obsolete - IConventionEntityType? IConventionModel.AddEntityType( - string name, - string definingNavigationName, - IConventionEntityType definingEntityType, - bool fromDataAnnotation) - => AddEntityType( - name, definingNavigationName, (EntityType)definingEntityType, - fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); - /// /// 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 @@ -1623,22 +1607,6 @@ IMutableEntityType IMutableModel.AddEntityType( IMutableEntityType definingEntityType) => AddEntityType(type, definingNavigationName, (EntityType)definingEntityType, ConfigurationSource.Explicit)!; - /// - /// 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. - /// - [Obsolete, DebuggerStepThrough] // The interface didn't mark method obsolete - IConventionEntityType? IConventionModel.AddEntityType( - [DynamicallyAccessedMembers(IEntityType.DynamicallyAccessedMemberTypes)] Type type, - string definingNavigationName, - IConventionEntityType definingEntityType, - bool fromDataAnnotation) - => AddEntityType( - type, definingNavigationName, (EntityType)definingEntityType, - fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); - /// /// 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 diff --git a/src/EFCore/Metadata/RuntimeEntityType.cs b/src/EFCore/Metadata/RuntimeEntityType.cs index 9820d035d60..3cca9c22f8c 100644 --- a/src/EFCore/Metadata/RuntimeEntityType.cs +++ b/src/EFCore/Metadata/RuntimeEntityType.cs @@ -919,11 +919,6 @@ public virtual DebugView DebugView IReadOnlyCollection IReadOnlyEntityType.GetDeclaredQueryFilters() => (IReadOnlyCollection?)this[CoreAnnotationNames.QueryFilter] ?? []; - /// - [DebuggerStepThrough, Obsolete("Use GetDeclaredQueryFilters() instead.")] - LambdaExpression? IReadOnlyEntityType.GetQueryFilter() - => ((IReadOnlyEntityType)this).GetDeclaredQueryFilters().FirstOrDefault(f => f.IsAnonymous)?.Expression; - /// [DebuggerStepThrough] IQueryFilter? IReadOnlyEntityType.FindDeclaredQueryFilter(string? filterKey) diff --git a/src/EFCore/Metadata/RuntimeModel.cs b/src/EFCore/Metadata/RuntimeModel.cs index 0ebc492ea0d..aa3a7689d6e 100644 --- a/src/EFCore/Metadata/RuntimeModel.cs +++ b/src/EFCore/Metadata/RuntimeModel.cs @@ -40,19 +40,6 @@ public class RuntimeModel : RuntimeAnnotatableBase, IRuntimeModel private readonly ConcurrentDictionary _clrTypeNameMap = new(); private readonly ConcurrentDictionary _adHocEntityTypes = new(); - /// - /// 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. - /// - [EntityFrameworkInternal, Obsolete("Use a constructor with parameters")] - public RuntimeModel() - { - _entityTypes = new Dictionary(StringComparer.Ordinal); - _typeConfigurations = new Dictionary(); - } - /// /// 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 @@ -72,22 +59,6 @@ public RuntimeModel( _typeConfigurations = new Dictionary(typeConfigurationCount); } - /// - /// Sets a value indicating whether should be called. - /// - [Obsolete("This is set in the constructor now")] - public virtual void SetSkipDetectChanges(bool skipDetectChanges) - => _skipDetectChanges = skipDetectChanges; - - /// - /// 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. - /// - [EntityFrameworkInternal, Obsolete("This is set in the constructor now")] - public virtual Guid ModelId { get => _modelId; set => _modelId = value; } - /// /// Adds an entity type with a defining navigation to the model. /// diff --git a/src/EFCore/Query/ParameterQueryRootExpression.cs b/src/EFCore/Query/ParameterQueryRootExpression.cs index 3a9272af08d..3d7c4454c3d 100644 --- a/src/EFCore/Query/ParameterQueryRootExpression.cs +++ b/src/EFCore/Query/ParameterQueryRootExpression.cs @@ -58,41 +58,4 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// protected override void Print(ExpressionPrinter expressionPrinter) => expressionPrinter.Visit(QueryParameterExpression); - - /// - /// This constructor has been obsoleted, use the constructor accepting QueryParameterExpression instead. - /// - [Obsolete("Use the constructor accepting QueryParameterExpression instead.")] - public ParameterQueryRootExpression( - IAsyncQueryProvider asyncQueryProvider, - Type elementType, - ParameterExpression parameterExpression) - : this( - asyncQueryProvider, - elementType, - new QueryParameterExpression( - parameterExpression.Name ?? throw new ArgumentException(CoreStrings.ParameterExpressionMustHaveName(parameterExpression)), - parameterExpression.Type)) - { - } - - /// - /// This constructor has been obsoleted, use the constructor accepting QueryParameterExpression instead. - /// - [Obsolete("Use the constructor accepting QueryParameterExpression instead.")] - public ParameterQueryRootExpression(Type elementType, ParameterExpression parameterExpression) - : this( - elementType, - new QueryParameterExpression( - parameterExpression.Name ?? throw new ArgumentException(CoreStrings.ParameterExpressionMustHaveName(parameterExpression)), - parameterExpression.Type)) - { - } - - /// - /// This constructor has been obsoleted, use QueryParameterExpression instead. - /// - [Obsolete("Use QueryParameterExpression instead.")] - public virtual ParameterExpression ParameterExpression - => Parameter(QueryParameterExpression.Type, QueryParameterExpression.Name); } diff --git a/src/EFCore/Storage/CoreTypeMapping.cs b/src/EFCore/Storage/CoreTypeMapping.cs index 95063a379fc..4ee4f02dba3 100644 --- a/src/EFCore/Storage/CoreTypeMapping.cs +++ b/src/EFCore/Storage/CoreTypeMapping.cs @@ -202,11 +202,6 @@ protected CoreTypeMapping(CoreTypeMappingParameters parameters) { _providerValueComparer = parameters.ProviderValueComparer; } - -#pragma warning disable CS0612 // Type or member is obsolete - ValueGeneratorFactory = parameters.ValueGeneratorFactory - ?? converter?.MappingHints?.ValueGeneratorFactory; -#pragma warning restore CS0612 // Type or member is obsolete } /// @@ -230,13 +225,6 @@ protected CoreTypeMapping(CoreTypeMappingParameters parameters) public virtual ValueConverter? Converter => Parameters.Converter; - /// - /// An optional factory for creating a specific to use with - /// this mapping. - /// - [Obsolete] - public virtual Func? ValueGeneratorFactory { get; } - /// /// A adds custom value snapshotting and comparison for /// CLR types that cannot be compared with diff --git a/src/EFCore/Storage/ITypeMappingSource.cs b/src/EFCore/Storage/ITypeMappingSource.cs index 6a54ce3d794..0df5f984251 100644 --- a/src/EFCore/Storage/ITypeMappingSource.cs +++ b/src/EFCore/Storage/ITypeMappingSource.cs @@ -43,19 +43,6 @@ public interface ITypeMappingSource /// The type mapping, or if none was found. CoreTypeMapping? FindMapping(IElementType elementType); - /// - /// Finds the type mapping for a given representing - /// a field or a property of a CLR type. - /// - /// - /// Note: Only call this method if there is no available, otherwise - /// call - /// - /// The field or property. - /// The type mapping, or if none was found. - [Obsolete("Use overload with IModel")] - CoreTypeMapping? FindMapping(MemberInfo member); - /// /// Finds the type mapping for a given representing /// a field or a property of a CLR type. diff --git a/src/EFCore/Storage/TypeMappingSourceBase.cs b/src/EFCore/Storage/TypeMappingSourceBase.cs index 1477ee0fb6d..fe2f88ff815 100644 --- a/src/EFCore/Storage/TypeMappingSourceBase.cs +++ b/src/EFCore/Storage/TypeMappingSourceBase.cs @@ -118,7 +118,12 @@ protected virtual void ValidateMapping( /// The type mapping, or if none was found. public abstract CoreTypeMapping? FindMapping(Type type, IModel model, CoreTypeMapping? elementMapping = null); - /// + /// + /// Finds the type mapping for a given representing + /// a field or a property of a CLR type. + /// + /// The field or property. + /// The type mapping, or if none was found. public abstract CoreTypeMapping? FindMapping(MemberInfo member); /// diff --git a/src/EFCore/Storage/ValueConversion/ConverterMappingHints.cs b/src/EFCore/Storage/ValueConversion/ConverterMappingHints.cs index ab019c03911..f2196942c70 100644 --- a/src/EFCore/Storage/ValueConversion/ConverterMappingHints.cs +++ b/src/EFCore/Storage/ValueConversion/ConverterMappingHints.cs @@ -22,21 +22,16 @@ public class ConverterMappingHints /// The suggested precision of the mapped data type. /// The suggested scale of the mapped data type. /// Whether the mapped data type should support Unicode. - /// An optional factory for creating a specific . public ConverterMappingHints( int? size = null, int? precision = null, int? scale = null, - bool? unicode = null, - Func? valueGeneratorFactory = null) + bool? unicode = null) { Size = size; Precision = precision; Scale = scale; IsUnicode = unicode; -#pragma warning disable CS0612 // Type or member is obsolete - ValueGeneratorFactory = valueGeneratorFactory; -#pragma warning restore CS0612 // Type or member is obsolete } /// @@ -55,10 +50,7 @@ public virtual ConverterMappingHints With(ConverterMappingHints? hints) hints.Size ?? Size, hints.Precision ?? Precision, hints.Scale ?? Scale, - hints.IsUnicode ?? IsUnicode, -#pragma warning disable CS0612 // Type or member is obsolete - hints.ValueGeneratorFactory ?? ValueGeneratorFactory) -#pragma warning restore CS0612 // Type or member is obsolete + hints.IsUnicode ?? IsUnicode) : hints.OverrideWith(this); /// @@ -77,10 +69,7 @@ public virtual ConverterMappingHints OverrideWith(ConverterMappingHints? hints) Size ?? hints.Size, Precision ?? hints.Precision, Scale ?? hints.Scale, - IsUnicode ?? hints.IsUnicode, -#pragma warning disable CS0612 // Type or member is obsolete - ValueGeneratorFactory ?? hints.ValueGeneratorFactory) -#pragma warning restore CS0612 // Type or member is obsolete + IsUnicode ?? hints.IsUnicode) : hints.With(this); /// @@ -102,11 +91,4 @@ public virtual ConverterMappingHints OverrideWith(ConverterMappingHints? hints) /// Whether the mapped data type should support Unicode. /// public virtual bool? IsUnicode { get; } - - /// - /// An optional factory for creating a specific to use for model - /// values when this converter is being used. - /// - [Obsolete] - public virtual Func? ValueGeneratorFactory { get; } } diff --git a/src/EFCore/Storage/ValueConversion/GuidToBytesConverter.cs b/src/EFCore/Storage/ValueConversion/GuidToBytesConverter.cs index 3e3465b66a7..66424a8a3e1 100644 --- a/src/EFCore/Storage/ValueConversion/GuidToBytesConverter.cs +++ b/src/EFCore/Storage/ValueConversion/GuidToBytesConverter.cs @@ -12,7 +12,7 @@ namespace Microsoft.EntityFrameworkCore.Storage.ValueConversion; public class GuidToBytesConverter : ValueConverter { private static readonly ConverterMappingHints DefaultHints - = new(size: 16, valueGeneratorFactory: (_, _) => new SequentialGuidValueGenerator()); + = new(size: 16); /// /// Creates a new instance of this converter. diff --git a/src/EFCore/Storage/ValueConversion/Internal/StringGuidConverter.cs b/src/EFCore/Storage/ValueConversion/Internal/StringGuidConverter.cs index a6e2fe71f17..238288ee7ab 100644 --- a/src/EFCore/Storage/ValueConversion/Internal/StringGuidConverter.cs +++ b/src/EFCore/Storage/ValueConversion/Internal/StringGuidConverter.cs @@ -19,7 +19,7 @@ public class StringGuidConverter : ValueConverter // ReSharper disable once StaticMemberInGenericType protected static readonly ConverterMappingHints DefaultHints - = new(size: 36, valueGeneratorFactory: (_, _) => new SequentialGuidValueGenerator()); + = new(size: 36); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/ValueGeneration/IValueGeneratorSelector.cs b/src/EFCore/ValueGeneration/IValueGeneratorSelector.cs index bebafddcde2..c50d605bd80 100644 --- a/src/EFCore/ValueGeneration/IValueGeneratorSelector.cs +++ b/src/EFCore/ValueGeneration/IValueGeneratorSelector.cs @@ -26,18 +26,6 @@ namespace Microsoft.EntityFrameworkCore.ValueGeneration; /// public interface IValueGeneratorSelector { - /// - /// Selects the appropriate value generator for a given property. - /// - /// The property to get the value generator for. - /// - /// The type that the value generator will be used for. When called on inherited properties on derived types, - /// this type may be different from the declaring type for - /// - /// The value generator to be used. - [Obsolete("Use TrySelect and throw if needed when the generator is not found.")] - ValueGenerator? Select(IProperty property, ITypeBase typeBase); - /// /// Selects the appropriate value generator for a given property, if available. /// diff --git a/src/EFCore/ValueGeneration/ValueGeneratorSelector.cs b/src/EFCore/ValueGeneration/ValueGeneratorSelector.cs index 4faf826bf27..c26f244831d 100644 --- a/src/EFCore/ValueGeneration/ValueGeneratorSelector.cs +++ b/src/EFCore/ValueGeneration/ValueGeneratorSelector.cs @@ -44,14 +44,6 @@ public ValueGeneratorSelector(ValueGeneratorSelectorDependencies dependencies) /// protected virtual ValueGeneratorSelectorDependencies Dependencies { get; } - /// - [Obsolete("Use TrySelect and throw if needed when the generator is not found.")] - public virtual ValueGenerator? Select(IProperty property, ITypeBase typeBase) - => Cache.GetOrAdd( - property, typeBase, (p, t) => Find(p, t) - ?? throw new NotSupportedException( - CoreStrings.NoValueGenerator(p.Name, p.DeclaringType.DisplayName(), p.ClrType.ShortDisplayName()))); - /// public virtual bool TrySelect(IProperty property, ITypeBase typeBase, out ValueGenerator? valueGenerator) { @@ -65,43 +57,9 @@ public virtual bool TrySelect(IProperty property, ITypeBase typeBase, out ValueG private static ValueGenerator? CreateFromFactory(IProperty property, ITypeBase structuralType) { var factory = property.GetValueGeneratorFactory(); - if (factory == null) - { - var mapping = property.GetTypeMapping(); -#pragma warning disable CS0612 // Type or member is obsolete - if (mapping.ValueGeneratorFactory != null - && structuralType is IEntityType) - { - factory = (p, t) => mapping.ValueGeneratorFactory.Invoke(p, (IEntityType)t); - } -#pragma warning restore CS0612 // Type or member is obsolete - } - return factory?.Invoke(property, structuralType); } - /// - /// Creates a new value generator for the given property. - /// - /// The property to get the value generator for. - /// - /// The entity type that the value generator will be used for. When called on inherited properties on derived entity types, - /// this entity type may be different from the declared entity type on - /// - /// The newly created value generator. - [Obsolete("Use TryCreate and throw if needed when the generator is not found.")] - public virtual ValueGenerator Create(IProperty property, ITypeBase typeBase) - { - if (!TryCreate(property, typeBase, out var valueGenerator)) - { - throw new NotSupportedException( - CoreStrings.NoValueGenerator( - property.Name, property.DeclaringType.DisplayName(), property.DeclaringType.ClrType.ShortDisplayName())); - } - - return valueGenerator!; - } - /// /// Creates a new value generator for the given property. /// diff --git a/test/EFCore.Cosmos.FunctionalTests/ModelBuilding/CosmosModelBuilderGenericTest.cs b/test/EFCore.Cosmos.FunctionalTests/ModelBuilding/CosmosModelBuilderGenericTest.cs index a69955f7a2f..6560246328a 100644 --- a/test/EFCore.Cosmos.FunctionalTests/ModelBuilding/CosmosModelBuilderGenericTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/ModelBuilding/CosmosModelBuilderGenericTest.cs @@ -1114,10 +1114,6 @@ public virtual void Can_use_shared_type_as_join_entity_with_partition_keys() Assert.Equal("DbContext", joinType.GetContainer()); Assert.Equal(["PartitionId"], joinType.GetPartitionKeyPropertyNames()); Assert.Equal("PartitionId", joinType.FindPrimaryKey()!.Properties.Last().Name); - -#pragma warning disable CS0618 // Type or member is obsolete - Assert.Equal("PartitionId", joinType.GetPartitionKeyPropertyName()); -#pragma warning restore CS0618 // Type or member is obsolete } [ConditionalFact] @@ -1215,10 +1211,6 @@ public virtual void Can_use_implicit_join_entity_with_partition_keys() Assert.Equal("DbContext", joinType.GetContainer()); Assert.Equal(["PartitionId"], joinType.GetPartitionKeyPropertyNames()); Assert.Equal("PartitionId", joinType.FindPrimaryKey()!.Properties.Last().Name); - -#pragma warning disable CS0618 // Type or member is obsolete - Assert.Equal("PartitionId", joinType.GetPartitionKeyPropertyName()); -#pragma warning restore CS0618 // Type or member is obsolete } [ConditionalFact] @@ -1311,10 +1303,6 @@ public virtual void Can_use_implicit_join_entity_with_partition_keys_changed() Assert.Equal("DbContext", joinType.GetContainer()); Assert.Equal(["Partition2Id"], joinType.GetPartitionKeyPropertyNames()); Assert.Equal("Partition2Id", joinType.FindPrimaryKey()!.Properties.Last().Name); - -#pragma warning disable CS0618 // Type or member is obsolete - Assert.Equal("Partition2Id", joinType.GetPartitionKeyPropertyName()); -#pragma warning restore CS0618 // Type or member is obsolete } public override void Join_type_is_automatically_configured_by_convention() diff --git a/test/EFCore.Cosmos.Tests/Extensions/CosmosBuilderExtensionsTest.cs b/test/EFCore.Cosmos.Tests/Extensions/CosmosBuilderExtensionsTest.cs index 1888a84920f..87864735901 100644 --- a/test/EFCore.Cosmos.Tests/Extensions/CosmosBuilderExtensionsTest.cs +++ b/test/EFCore.Cosmos.Tests/Extensions/CosmosBuilderExtensionsTest.cs @@ -43,13 +43,11 @@ public void Can_get_and_set_partition_key_name() ConfigurationSource.Convention, ((IConventionEntityType)entityType).GetPartitionKeyPropertyNamesConfigurationSource()); -#pragma warning disable CS0618 // Type or member is obsolete - ((IConventionEntityType)entityType).Builder.HasPartitionKey("pk"); - Assert.Equal("pk", entityType.GetPartitionKeyPropertyName()); + ((IConventionEntityType)entityType).Builder.HasPartitionKey(["pk"]); + Assert.Equal("pk", entityType.GetPartitionKeyPropertyNames().Single()); Assert.Equal( ConfigurationSource.Convention, - ((IConventionEntityType)entityType).GetPartitionKeyPropertyNameConfigurationSource()); -#pragma warning restore CS0618 // Type or member is obsolete + ((IConventionEntityType)entityType).GetPartitionKeyPropertyNamesConfigurationSource()); entityTypeBuilder.HasPartitionKey("pk"); @@ -60,24 +58,17 @@ public void Can_get_and_set_partition_key_name() Assert.False(((IConventionEntityType)entityType).Builder.CanSetPartitionKey(["partition"])); -#pragma warning disable CS0618 // Type or member is obsolete - Assert.Equal("pk", entityType.GetPartitionKeyPropertyName()); + Assert.Equal("pk", entityType.GetPartitionKeyPropertyNames().Single()); Assert.Equal( ConfigurationSource.Explicit, - ((IConventionEntityType)entityType).GetPartitionKeyPropertyNameConfigurationSource()); + ((IConventionEntityType)entityType).GetPartitionKeyPropertyNamesConfigurationSource()); - Assert.False(((IConventionEntityType)entityType).Builder.CanSetPartitionKey("partition")); -#pragma warning restore CS0618 // Type or member is obsolete + Assert.False(((IConventionEntityType)entityType).Builder.CanSetPartitionKey(["partition"])); entityTypeBuilder.HasPartitionKey(null); Assert.Empty(entityType.GetPartitionKeyPropertyNames()); Assert.Null(((IConventionEntityType)entityType).GetPartitionKeyPropertyNamesConfigurationSource()); - -#pragma warning disable CS0618 // Type or member is obsolete - Assert.Null(entityType.GetPartitionKeyPropertyName()); - Assert.Null(((IConventionEntityType)entityType).GetPartitionKeyPropertyNameConfigurationSource()); -#pragma warning restore CS0618 // Type or member is obsolete } [ConditionalFact] diff --git a/test/EFCore.Cosmos.Tests/Extensions/CosmosMetadataExtensionsTest.cs b/test/EFCore.Cosmos.Tests/Extensions/CosmosMetadataExtensionsTest.cs index 7e6d8ba36bf..229df3b4a06 100644 --- a/test/EFCore.Cosmos.Tests/Extensions/CosmosMetadataExtensionsTest.cs +++ b/test/EFCore.Cosmos.Tests/Extensions/CosmosMetadataExtensionsTest.cs @@ -66,23 +66,21 @@ public void Can_get_and_set_partition_key_name_obsolete() var entityType = modelBuilder .Entity().Metadata; -#pragma warning disable CS0618 // Type or member is obsolete - Assert.Null(entityType.GetPartitionKeyPropertyName()); + Assert.Empty(entityType.GetPartitionKeyPropertyNames()); - ((IConventionEntityType)entityType).SetPartitionKeyPropertyName("pk"); - Assert.Equal("pk", entityType.GetPartitionKeyPropertyName()); + ((IConventionEntityType)entityType).SetPartitionKeyPropertyNames(["pk"]); + Assert.Equal("pk", entityType.GetPartitionKeyPropertyNames().Single()); Assert.Equal( - ConfigurationSource.Convention, ((IConventionEntityType)entityType).GetPartitionKeyPropertyNameConfigurationSource()); + ConfigurationSource.Convention, ((IConventionEntityType)entityType).GetPartitionKeyPropertyNamesConfigurationSource()); - entityType.SetPartitionKeyPropertyName("pk"); - Assert.Equal("pk", entityType.GetPartitionKeyPropertyName()); + entityType.SetPartitionKeyPropertyNames(["pk"]); + Assert.Equal("pk", entityType.GetPartitionKeyPropertyNames().Single()); Assert.Equal( - ConfigurationSource.Explicit, ((IConventionEntityType)entityType).GetPartitionKeyPropertyNameConfigurationSource()); + ConfigurationSource.Explicit, ((IConventionEntityType)entityType).GetPartitionKeyPropertyNamesConfigurationSource()); - entityType.SetPartitionKeyPropertyName(null); - Assert.Null(entityType.GetPartitionKeyPropertyName()); - Assert.Null(((IConventionEntityType)entityType).GetPartitionKeyPropertyNameConfigurationSource()); -#pragma warning restore CS0618 // Type or member is obsolete + entityType.SetPartitionKeyPropertyNames(null); + Assert.Empty(entityType.GetPartitionKeyPropertyNames()); + Assert.Null(((IConventionEntityType)entityType).GetPartitionKeyPropertyNamesConfigurationSource()); } [ConditionalFact] diff --git a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorSqliteTest.cs b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorSqliteTest.cs index c7249420b52..de1fd2b78f0 100644 --- a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorSqliteTest.cs +++ b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorSqliteTest.cs @@ -160,7 +160,6 @@ protected override CSharpMigrationsGenerator CreateMigrationsGenerator() var generator = new CSharpMigrationsGenerator( new MigrationsCodeGeneratorDependencies( - sqliteTypeMappingSource, sqliteAnnotationCodeGenerator), new CSharpMigrationsGeneratorDependencies( codeHelper, diff --git a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.ModelSnapshot.cs b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.ModelSnapshot.cs index 145e0c2fd26..e9e100e9184 100644 --- a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.ModelSnapshot.cs +++ b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.ModelSnapshot.cs @@ -2379,7 +2379,7 @@ public virtual void EntityType_Fluent_APIs_are_properly_generated() b.ToTable("EntityWithOneProperty", "DefaultSchema"); - SqlServerEntityTypeBuilderExtensions.IsMemoryOptimized(b); + b.ToTable(tb => tb.IsMemoryOptimized()); }); """), o => Assert.True(o.GetEntityTypes().Single().IsMemoryOptimized())); @@ -9110,7 +9110,6 @@ [new SqlServerNetTopologySuiteTypeMappingSourcePlugin(NtsGeometryServices.Instan var generator = new CSharpMigrationsGenerator( new MigrationsCodeGeneratorDependencies( - sqlServerTypeMappingSource, sqlServerAnnotationCodeGenerator), new CSharpMigrationsGeneratorDependencies( codeHelper, diff --git a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.cs b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.cs index 6c6d3c3e73c..8680507381b 100644 --- a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.cs +++ b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.cs @@ -98,9 +98,6 @@ public void Test_new_annotations_handled_for_entity_types() // Appears on entity type but requires specific model (i.e. owned types that can map to json, otherwise validation throws) RelationalAnnotationNames.ContainerColumnName, RelationalAnnotationNames.ContainerColumnType, -#pragma warning disable CS0618 - RelationalAnnotationNames.ContainerColumnTypeMapping, -#pragma warning restore CS0618 RelationalAnnotationNames.StoreType, RelationalAnnotationNames.UseNamedDefaultConstraints, RelationalAnnotationNames.IsForeignKeyExcludedFromMigrations @@ -259,9 +256,6 @@ public void Test_new_annotations_handled_for_properties() RelationalAnnotationNames.FieldValueGetter, RelationalAnnotationNames.ContainerColumnName, RelationalAnnotationNames.ContainerColumnType, -#pragma warning disable CS0618 - RelationalAnnotationNames.ContainerColumnTypeMapping, -#pragma warning restore CS0618 RelationalAnnotationNames.JsonPropertyName, RelationalAnnotationNames.StoreType, RelationalAnnotationNames.UseNamedDefaultConstraints, @@ -488,7 +482,6 @@ public void Snapshot_with_enum_discriminator_uses_converted_values() var generator = new CSharpMigrationsGenerator( new MigrationsCodeGeneratorDependencies( - sqlServerTypeMappingSource, sqlServerAnnotationCodeGenerator), new CSharpMigrationsGeneratorDependencies( codeHelper, diff --git a/test/EFCore.Design.Tests/Migrations/Design/MigrationScaffolderTest.cs b/test/EFCore.Design.Tests/Migrations/Design/MigrationScaffolderTest.cs index e95faedd9a9..5726aacca5c 100644 --- a/test/EFCore.Design.Tests/Migrations/Design/MigrationScaffolderTest.cs +++ b/test/EFCore.Design.Tests/Migrations/Design/MigrationScaffolderTest.cs @@ -108,7 +108,6 @@ var migrationAssembly [ new CSharpMigrationsGenerator( new MigrationsCodeGeneratorDependencies( - sqlServerTypeMappingSource, sqlServerAnnotationCodeGenerator), new CSharpMigrationsGeneratorDependencies( code, diff --git a/test/EFCore.InMemory.Tests/ValueGeneration/InMemoryValueGeneratorSelectorTest.cs b/test/EFCore.InMemory.Tests/ValueGeneration/InMemoryValueGeneratorSelectorTest.cs index b29efae2699..ead4687a5f5 100644 --- a/test/EFCore.InMemory.Tests/ValueGeneration/InMemoryValueGeneratorSelectorTest.cs +++ b/test/EFCore.InMemory.Tests/ValueGeneration/InMemoryValueGeneratorSelectorTest.cs @@ -9,38 +9,6 @@ namespace Microsoft.EntityFrameworkCore.ValueGeneration; public class InMemoryValueGeneratorSelectorTest { - [ConditionalFact] - public void Returns_built_in_generators_for_types_setup_for_value_generation() - { - var model = BuildModel(); - var entityType = model.FindEntityType(typeof(AnEntity)); - - var selector = InMemoryTestHelpers.Instance.CreateContextServices(model).GetRequiredService(); - -#pragma warning disable CS0618 // Type or member is obsolete - Assert.IsType(selector.Select(entityType.FindProperty("Custom"), entityType)); - Assert.IsType>(selector.Select(entityType.FindProperty("Id"), entityType)); - Assert.IsType>(selector.Select(entityType.FindProperty("Long"), entityType)); - Assert.IsType>(selector.Select(entityType.FindProperty("Short"), entityType)); - Assert.IsType>(selector.Select(entityType.FindProperty("Byte"), entityType)); - Assert.IsType>(selector.Select(entityType.FindProperty("NullableInt"), entityType)); - Assert.IsType>(selector.Select(entityType.FindProperty("NullableLong"), entityType)); - Assert.IsType>(selector.Select(entityType.FindProperty("NullableShort"), entityType)); - Assert.IsType>(selector.Select(entityType.FindProperty("NullableByte"), entityType)); - Assert.IsType>(selector.Select(entityType.FindProperty("UInt"), entityType)); - Assert.IsType>(selector.Select(entityType.FindProperty("ULong"), entityType)); - Assert.IsType>(selector.Select(entityType.FindProperty("UShort"), entityType)); - Assert.IsType>(selector.Select(entityType.FindProperty("SByte"), entityType)); - Assert.IsType>(selector.Select(entityType.FindProperty("NullableUInt"), entityType)); - Assert.IsType>(selector.Select(entityType.FindProperty("NullableULong"), entityType)); - Assert.IsType>(selector.Select(entityType.FindProperty("NullableUShort"), entityType)); - Assert.IsType>(selector.Select(entityType.FindProperty("NullableSByte"), entityType)); - Assert.IsType(selector.Select(entityType.FindProperty("String"), entityType)); - Assert.IsType(selector.Select(entityType.FindProperty("Guid"), entityType)); - Assert.IsType(selector.Select(entityType.FindProperty("Binary"), entityType)); -#pragma warning restore CS0618 // Type or member is obsolete - } - [ConditionalFact] public void Returns_built_in_generators_for_types_setup_for_value_generation_using_Try_method() { @@ -97,60 +65,35 @@ public void Can_create_factories_for_all_integer_types(bool useTry) var model = BuildModel(); var entityType = model.FindEntityType(typeof(AnEntity))!; - Assert.Equal(1, CreateAndUseFactory(entityType.FindProperty("Id"), useTry)); - Assert.Equal(1L, CreateAndUseFactory(entityType.FindProperty("Long"), useTry)); - Assert.Equal((short)1, CreateAndUseFactory(entityType.FindProperty("Short"), useTry)); - Assert.Equal((byte)1, CreateAndUseFactory(entityType.FindProperty("Byte"), useTry)); - Assert.Equal((int?)1, CreateAndUseFactory(entityType.FindProperty("NullableInt"), useTry)); - Assert.Equal((long?)1, CreateAndUseFactory(entityType.FindProperty("NullableLong"), useTry)); - Assert.Equal((short?)1, CreateAndUseFactory(entityType.FindProperty("NullableShort"), useTry)); - Assert.Equal((byte?)1, CreateAndUseFactory(entityType.FindProperty("NullableByte"), useTry)); - Assert.Equal((uint)1, CreateAndUseFactory(entityType.FindProperty("UInt"), useTry)); - Assert.Equal((ulong)1, CreateAndUseFactory(entityType.FindProperty("ULong"), useTry)); - Assert.Equal((ushort)1, CreateAndUseFactory(entityType.FindProperty("UShort"), useTry)); - Assert.Equal((sbyte)1, CreateAndUseFactory(entityType.FindProperty("SByte"), useTry)); - Assert.Equal((uint?)1, CreateAndUseFactory(entityType.FindProperty("NullableUInt"), useTry)); - Assert.Equal((ulong?)1, CreateAndUseFactory(entityType.FindProperty("NullableULong"), useTry)); - Assert.Equal((ushort?)1, CreateAndUseFactory(entityType.FindProperty("NullableUShort"), useTry)); - Assert.Equal((sbyte?)1, CreateAndUseFactory(entityType.FindProperty("NullableSByte"), useTry)); + Assert.Equal(1, CreateAndUseFactory(entityType.FindProperty("Id"))); + Assert.Equal(1L, CreateAndUseFactory(entityType.FindProperty("Long"))); + Assert.Equal((short)1, CreateAndUseFactory(entityType.FindProperty("Short"))); + Assert.Equal((byte)1, CreateAndUseFactory(entityType.FindProperty("Byte"))); + Assert.Equal((int?)1, CreateAndUseFactory(entityType.FindProperty("NullableInt"))); + Assert.Equal((long?)1, CreateAndUseFactory(entityType.FindProperty("NullableLong"))); + Assert.Equal((short?)1, CreateAndUseFactory(entityType.FindProperty("NullableShort"))); + Assert.Equal((byte?)1, CreateAndUseFactory(entityType.FindProperty("NullableByte"))); + Assert.Equal((uint)1, CreateAndUseFactory(entityType.FindProperty("UInt"))); + Assert.Equal((ulong)1, CreateAndUseFactory(entityType.FindProperty("ULong"))); + Assert.Equal((ushort)1, CreateAndUseFactory(entityType.FindProperty("UShort"))); + Assert.Equal((sbyte)1, CreateAndUseFactory(entityType.FindProperty("SByte"))); + Assert.Equal((uint?)1, CreateAndUseFactory(entityType.FindProperty("NullableUInt"))); + Assert.Equal((ulong?)1, CreateAndUseFactory(entityType.FindProperty("NullableULong"))); + Assert.Equal((ushort?)1, CreateAndUseFactory(entityType.FindProperty("NullableUShort"))); + Assert.Equal((sbyte?)1, CreateAndUseFactory(entityType.FindProperty("NullableSByte"))); } - private static object CreateAndUseFactory(IProperty property, bool useTry = true) + private static object CreateAndUseFactory(IProperty property) { var model = BuildModel(); var selector = InMemoryTestHelpers.Instance.CreateContextServices(model).GetRequiredService(); - ValueGenerator generator; - if (useTry) - { - selector.TrySelect(property, property.DeclaringType, out generator); - } - else - { -#pragma warning disable CS0618 // Type or member is obsolete - generator = selector.Select(property, property.DeclaringType); -#pragma warning restore CS0618 // Type or member is obsolete - } + selector.TrySelect(property, property.DeclaringType, out var generator); return generator!.Next(null!); } - [ConditionalFact] - public void Throws_for_unsupported_combinations() - { - var model = BuildModel(); - var entityType = model.FindEntityType(typeof(AnEntity)); - - var selector = InMemoryTestHelpers.Instance.CreateContextServices(model).GetRequiredService(); - - Assert.Equal( - CoreStrings.NoValueGenerator("Float", "AnEntity", "float"), -#pragma warning disable CS0618 // Type or member is obsolete - Assert.Throws(() => selector.Select(entityType.FindProperty("Float"), entityType)).Message); -#pragma warning restore CS0618 // Type or member is obsolete - } - [ConditionalFact] public void Returns_null_for_unsupported_combinations() { diff --git a/test/EFCore.Relational.Specification.Tests/TransactionTestBase.cs b/test/EFCore.Relational.Specification.Tests/TransactionTestBase.cs index f9e126392f8..dcee48ef94c 100644 --- a/test/EFCore.Relational.Specification.Tests/TransactionTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/TransactionTestBase.cs @@ -52,43 +52,6 @@ await context.AddAsync( } } -#pragma warning disable CS0618 // AutoTransactionsEnabled is obsolete - [ConditionalTheory, InlineData(true), InlineData(false)] - public virtual async Task SaveChanges_can_be_used_with_AutoTransactionsEnabled_false(bool async) - { - using (var context = CreateContext()) - { - context.Database.AutoTransactionsEnabled = false; - - await context.AddAsync( - new TransactionCustomer { Id = -77, Name = "Bobble" }); - - context.Entry(context.Set().OrderBy(c => c.Id).Last()).State = EntityState.Added; - - if (async) - { - await Assert.ThrowsAsync(() => context.SaveChangesAsync()); - } - else - { - Assert.Throws(() => context.SaveChanges()); - } - - context.Database.AutoTransactionBehavior = AutoTransactionBehavior.WhenNeeded; - } - - Assert.DoesNotContain(Fixture.ListLoggerFactory.Log, l => l.Id == RelationalEventId.TransactionStarted); - Assert.DoesNotContain(Fixture.ListLoggerFactory.Log, l => l.Id == RelationalEventId.TransactionCommitted); - - using (var context = CreateContext()) - { - Assert.Equal( - [-77, 1, 2], - context.Set().OrderBy(c => c.Id).Select(e => e.Id).ToList()); - } - } -#pragma warning restore CS0618 - [ConditionalTheory, InlineData(true), InlineData(false)] public virtual async Task SaveChanges_can_be_used_with_AutoTransactionBehavior_Always(bool async) { diff --git a/test/EFCore.SqlServer.FunctionalTests/ModelBuilding/SqlServerModelBuilderTestBase.cs b/test/EFCore.SqlServer.FunctionalTests/ModelBuilding/SqlServerModelBuilderTestBase.cs index e1b70082613..185d3bf3292 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ModelBuilding/SqlServerModelBuilderTestBase.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ModelBuilding/SqlServerModelBuilderTestBase.cs @@ -2062,9 +2062,6 @@ public virtual void Entity_mapped_to_json_and_unwound_afterwards_properly_cleans foreach (var outerOwnedEntity in outerOwnedEntities) { Assert.False(outerOwnedEntity.IsMappedToJson()); -#pragma warning disable CS0618 - Assert.Null(outerOwnedEntity.GetContainerColumnTypeMapping()); -#pragma warning restore CS0618 var myEnum = outerOwnedEntity.GetDeclaredProperties().Where(p => p.ClrType.IsEnum).Single(); var typeMapping = myEnum.FindRelationalTypeMapping()!; @@ -2077,9 +2074,6 @@ public virtual void Entity_mapped_to_json_and_unwound_afterwards_properly_cleans foreach (var ownedEntity in ownedEntities) { Assert.False(ownedEntity.IsMappedToJson()); -#pragma warning disable CS0618 - Assert.Null(ownedEntity.GetContainerColumnTypeMapping()); -#pragma warning restore CS0618 var myEnum = ownedEntity.GetDeclaredProperties().Where(p => p.ClrType.IsEnum).Single(); var typeMapping = myEnum.FindRelationalTypeMapping()!; Assert.True(typeMapping.Converter is EnumToNumberConverter); diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlServerConfigPatternsTest.cs b/test/EFCore.SqlServer.FunctionalTests/SqlServerConfigPatternsTest.cs index 25f21650525..150864270ea 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlServerConfigPatternsTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlServerConfigPatternsTest.cs @@ -412,42 +412,6 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) } } - public class AzureSqlDatabase - { - [InlineData(true), InlineData(false), ConditionalTheory] - public void Retry_on_failure_not_enabled_by_default_on_Azure_SQL(bool useAzure) - { - using var context = new NorthwindContext(useAzure); - - Assert.IsType(context.Database.CreateExecutionStrategy()); - } - - private class NorthwindContext(bool useAzure) : DbContext - { - private readonly bool _useAzure = useAzure; - - public DbSet Customers { get; set; } - - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - => optionsBuilder - .EnableServiceProviderCaching(false) - .UseSqlServer( - @"Server=test.database.windows.net:4040;Database=Test;ConnectRetryCount=0", - a => - { - if (_useAzure) - { -#pragma warning disable CS0618 // Type or member is obsolete - a.UseAzureSqlDefaults(false); -#pragma warning restore CS0618 // Type or member is obsolete - } - }); - - protected override void OnModelCreating(ModelBuilder modelBuilder) - => ConfigureModel(modelBuilder); - } - } - public class NonDefaultAzureSqlDatabase { [InlineData(true), InlineData(false), ConditionalTheory] diff --git a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs index 1f8b4bbaa05..c753d00a5df 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs @@ -37,10 +37,6 @@ public IRelationalCommandBuilder RemoveParameterAt(int index) return this; } - [Obsolete("Code trying to add parameter should add type mapped parameter using TypeMappingSource directly.")] - public IRelationalTypeMappingSource TypeMappingSource - => Dependencies.TypeMappingSource; - public IRelationalCommand Build() => new TestRelationalCommand( Dependencies, diff --git a/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs b/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs index 0a830251eb8..f8d4d4998d9 100644 --- a/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs +++ b/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs @@ -495,9 +495,13 @@ public void GenerateFluentApi_IEntityType_works_when_IsMemoryOptimized() var result = generator.GenerateFluentApiCalls(entityType, entityType.GetAnnotations().ToDictionary(a => a.Name, a => a)) .Single(); - Assert.Equal(nameof(SqlServerEntityTypeBuilderExtensions.IsMemoryOptimized), result.Method); - - Assert.Equal(0, result.Arguments.Count); + Assert.Equal(nameof(RelationalEntityTypeBuilderExtensions.ToTable), result.Method); + Assert.Single(result.Arguments); + var nestedClosure = Assert.IsType(result.Arguments[0]); + Assert.Equal("tb", nestedClosure.Parameter); + var memoryOptimizedCall = Assert.Single(nestedClosure.MethodCalls); + Assert.Equal(nameof(SqlServerTableBuilderExtensions.IsMemoryOptimized), memoryOptimizedCall.Method); + Assert.Equal(0, memoryOptimizedCall.Arguments.Count); } private SqlServerAnnotationCodeGenerator CreateGenerator() diff --git a/test/EFCore.SqlServer.Tests/ValueGeneration/SqlServerValueGeneratorSelectorTest.cs b/test/EFCore.SqlServer.Tests/ValueGeneration/SqlServerValueGeneratorSelectorTest.cs index 05241e064b7..f7a6c42fe02 100644 --- a/test/EFCore.SqlServer.Tests/ValueGeneration/SqlServerValueGeneratorSelectorTest.cs +++ b/test/EFCore.SqlServer.Tests/ValueGeneration/SqlServerValueGeneratorSelectorTest.cs @@ -62,18 +62,7 @@ private void AssertGenerator(string propertyName, bool useHiLo = fals private static ValueGenerator CreateValueGenerator(IValueGeneratorSelector selector, IProperty property, bool useTry) { - ValueGenerator generator; - if (useTry) - { - selector.TrySelect(property, property.DeclaringType, out generator); - } - else - { -#pragma warning disable CS0618 // Type or member is obsolete - generator = selector.Select(property, property.DeclaringType); -#pragma warning restore CS0618 // Type or member is obsolete - } - + selector.TrySelect(property, property.DeclaringType, out var generator); return generator; } @@ -174,27 +163,6 @@ public void Returns_built_in_generators_for_types_setup_for_value_generation_eve AssertGenerator("Binary", useKeySequence: true, useTry: useTry); } - [ConditionalFact] - public void Throws_for_unsupported_combinations() - { - var builder = InMemoryTestHelpers.Instance.CreateConventionBuilder(); - builder.Entity(b => - { - b.Property(e => e.TimeSpan).ValueGeneratedOnAdd(); - b.HasKey(e => e.TimeSpan); - }); - var model = builder.FinalizeModel(); - var entityType = model.FindEntityType(typeof(AnEntity)); - - var selector = SqlServerTestHelpers.Instance.CreateContextServices(model).GetRequiredService(); - - Assert.Equal( - CoreStrings.NoValueGenerator("TimeSpan", "AnEntity", "TimeSpan"), -#pragma warning disable CS0618 // Type or member is obsolete - Assert.Throws(() => selector.Select(entityType.FindProperty("TimeSpan"), entityType)).Message); -#pragma warning restore CS0618 // Type or member is obsolete - } - [ConditionalFact] public void Returns_null_for_unsupported_combinations() { diff --git a/test/EFCore.Tests/Infrastructure/CompiledModelProviderMismatchTest.cs b/test/EFCore.Tests/Infrastructure/CompiledModelProviderMismatchTest.cs index f3a9014d031..07ed9cae9de 100644 --- a/test/EFCore.Tests/Infrastructure/CompiledModelProviderMismatchTest.cs +++ b/test/EFCore.Tests/Infrastructure/CompiledModelProviderMismatchTest.cs @@ -89,9 +89,7 @@ public static IModel Instance private static RuntimeModel CreateModel() { -#pragma warning disable CS0618 // Type or member is obsolete - var model = new RuntimeModel(); -#pragma warning restore CS0618 + var model = new RuntimeModel(skipDetectChanges: false, modelId: Guid.Empty, entityTypeCount: 0); model.AddAnnotation(CoreAnnotationNames.ProductVersion, ProductInfo.GetVersion()); return model; } @@ -106,9 +104,7 @@ public static IModel Instance private static RuntimeModel CreateModel() { -#pragma warning disable CS0618 // Type or member is obsolete - var model = new RuntimeModel(); -#pragma warning restore CS0618 + var model = new RuntimeModel(skipDetectChanges: false, modelId: Guid.Empty, entityTypeCount: 0); model.AddAnnotation(CoreAnnotationNames.ProductVersion, ProductInfo.GetVersion()); return model; } @@ -123,9 +119,7 @@ public static IModel Instance private static RuntimeModel CreateModel() { -#pragma warning disable CS0618 // Type or member is obsolete - var model = new RuntimeModel(); -#pragma warning restore CS0618 + var model = new RuntimeModel(skipDetectChanges: false, modelId: Guid.Empty, entityTypeCount: 0); model.AddAnnotation(CoreAnnotationNames.ProductVersion, ProductInfo.GetVersion()); return model; } diff --git a/test/EFCore.Tests/Metadata/Conventions/IndexAttributeConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/IndexAttributeConventionTest.cs index fa2fbe7dc87..6376c97539c 100644 --- a/test/EFCore.Tests/Metadata/Conventions/IndexAttributeConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/IndexAttributeConventionTest.cs @@ -72,16 +72,6 @@ public void IndexAttribute_can_be_overriden_using_explicit_configuration() prop1 => Assert.Equal("B", prop1.Name)); } - [ConditionalFact] - public void IndexAttribute_with_no_property_names_throws() - { - var modelBuilder = InMemoryTestHelpers.Instance.CreateConventionBuilder(); - - Assert.Equal( - $"{AbstractionsStrings.CollectionArgumentIsEmpty} (Parameter 'propertyNames')", - Assert.Throws(() => modelBuilder.Entity()).Message); - } - [InlineData(typeof(EntityWithInvalidNullIndexProperty)), InlineData(typeof(EntityWithInvalidEmptyIndexProperty)), InlineData(typeof(EntityWithInvalidWhiteSpaceIndexProperty)), ConditionalTheory] public void IndexAttribute_properties_cannot_include_whitespace(Type entityTypeWithInvalidIndex) @@ -358,16 +348,6 @@ private class EntityWithIndexFromBaseType : BaseUnmappedEntityWithIndex public int D { get; set; } } -#pragma warning disable CS0618 - [Index] -#pragma warning restore CS0618 - private class EntityWithInvalidEmptyIndex - { - public int Id { get; set; } - public int A { get; set; } - public int B { get; set; } - } - [Index(nameof(A), (string)null, Name = "IndexOnAAndNull")] private class EntityWithInvalidNullIndexProperty { diff --git a/test/EFCore.Tests/Metadata/Internal/ClrPropertyGetterFactoryTest.cs b/test/EFCore.Tests/Metadata/Internal/ClrPropertyGetterFactoryTest.cs index af59f897177..4b7db850dcf 100644 --- a/test/EFCore.Tests/Metadata/Internal/ClrPropertyGetterFactoryTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/ClrPropertyGetterFactoryTest.cs @@ -136,9 +136,6 @@ public bool HasSentinelValueUsingContainingEntity(object entity, IReadOnlyList throw new NotImplementedException(); - IReadOnlyTypeBase IReadOnlyPropertyBase.DeclaringType => throw new NotImplementedException(); diff --git a/test/EFCore.Tests/Metadata/Internal/ClrPropertySetterFactoryTest.cs b/test/EFCore.Tests/Metadata/Internal/ClrPropertySetterFactoryTest.cs index 17fe3ac38f2..3dcd1f67d8b 100644 --- a/test/EFCore.Tests/Metadata/Internal/ClrPropertySetterFactoryTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/ClrPropertySetterFactoryTest.cs @@ -34,9 +34,6 @@ private class FakeProperty : Annotatable, IProperty, IClrPropertySetter public PropertyInfo PropertyInfo { get; } public FieldInfo FieldInfo { get; } - IReadOnlyEntityType IReadOnlyProperty.DeclaringEntityType - => throw new NotImplementedException(); - IReadOnlyTypeBase IReadOnlyPropertyBase.DeclaringType => throw new NotImplementedException(); diff --git a/test/EFCore.Tests/ValueGeneration/ValueGeneratorSelectorTest.cs b/test/EFCore.Tests/ValueGeneration/ValueGeneratorSelectorTest.cs index 7612f79ac0c..a915aa69f67 100644 --- a/test/EFCore.Tests/ValueGeneration/ValueGeneratorSelectorTest.cs +++ b/test/EFCore.Tests/ValueGeneration/ValueGeneratorSelectorTest.cs @@ -5,62 +5,6 @@ namespace Microsoft.EntityFrameworkCore.ValueGeneration; public class ValueGeneratorSelectorTest { - [ConditionalFact] - public void Returns_built_in_generators_for_types_setup_for_value_generation() - { - var model = BuildModel(); - var entityType = model.FindEntityType(typeof(AnEntity))!; - - var selector = new ValueGeneratorSelector( - new ValueGeneratorSelectorDependencies(new ValueGeneratorCache(new ValueGeneratorCacheDependencies()))); - -#pragma warning disable CS0618 // Type or member is obsolete - Assert.IsType(selector.Select(entityType.FindProperty("Custom")!, entityType)); - - Assert.Throws(() => selector.Select(entityType.FindProperty("Id")!, entityType)); - Assert.Throws(() => selector.Select(entityType.FindProperty("Long")!, entityType)); - Assert.Throws(() => selector.Select(entityType.FindProperty("Short")!, entityType)); - Assert.Throws(() => selector.Select(entityType.FindProperty("Byte")!, entityType)); - - Assert.Throws(() => selector.Select(entityType.FindProperty("NullableInt")!, entityType)); - Assert.Throws(() => selector.Select(entityType.FindProperty("NullableLong")!, entityType)); - Assert.Throws(() => selector.Select(entityType.FindProperty("NullableShort")!, entityType)); - Assert.Throws(() => selector.Select(entityType.FindProperty("NullableByte")!, entityType)); - - Assert.Throws(() => selector.Select(entityType.FindProperty("UInt")!, entityType)); - Assert.Throws(() => selector.Select(entityType.FindProperty("ULong")!, entityType)); - Assert.Throws(() => selector.Select(entityType.FindProperty("UShort")!, entityType)); - Assert.Throws(() => selector.Select(entityType.FindProperty("SByte")!, entityType)); - - Assert.Throws(() => selector.Select(entityType.FindProperty("NullableUInt")!, entityType)); - Assert.Throws(() => selector.Select(entityType.FindProperty("NullableULong")!, entityType)); - Assert.Throws(() => selector.Select(entityType.FindProperty("NullableUShort")!, entityType)); - Assert.Throws(() => selector.Select(entityType.FindProperty("NullableSByte")!, entityType)); - - Assert.Throws(() => selector.Select(entityType.FindProperty("Decimal")!, entityType)); - Assert.Throws(() => selector.Select(entityType.FindProperty("NullableDecimal")!, entityType)); - - Assert.Throws(() => selector.Select(entityType.FindProperty("Float")!, entityType)); - Assert.Throws(() => selector.Select(entityType.FindProperty("NullableFloat")!, entityType)); - - Assert.Throws(() => selector.Select(entityType.FindProperty("Double")!, entityType)); - Assert.Throws(() => selector.Select(entityType.FindProperty("NullableDouble")!, entityType)); - - Assert.Throws(() => selector.Select(entityType.FindProperty("DateTime")!, entityType)); - Assert.Throws(() => selector.Select(entityType.FindProperty("NullableDateTime")!, entityType)); - - Assert.Throws(() => selector.Select(entityType.FindProperty("DateTimeOffset")!, entityType)); - Assert.Throws(() => selector.Select(entityType.FindProperty("NullableDateTimeOffset")!, entityType)); - - Assert.IsType(selector.Select(entityType.FindProperty("String")!, entityType)); - - Assert.IsType(selector.Select(entityType.FindProperty("Guid")!, entityType)); - Assert.IsType(selector.Select(entityType.FindProperty("NullableGuid")!, entityType)); - - Assert.IsType(selector.Select(entityType.FindProperty("Binary")!, entityType)); -#pragma warning restore CS0618 // Type or member is obsolete - } - [ConditionalFact] public void Returns_built_in_generators_for_types_setup_for_value_generation_using_Try_method() { @@ -120,23 +64,6 @@ public void Returns_built_in_generators_for_types_setup_for_value_generation_usi selector.TrySelect(entityType.FindProperty("Binary")!, entityType, out generator) ? generator : null); } - [ConditionalFact] - public void Throws_for_unsupported_combinations() - { - var model = BuildModel(); - var entityType = model.FindEntityType(typeof(AnEntity)); - - var contextServices = InMemoryTestHelpers.Instance.CreateContextServices(model); - - var selector = contextServices.GetRequiredService(); - - Assert.Equal( - CoreStrings.NoValueGenerator("Random", "AnEntity", "char"), -#pragma warning disable CS0618 // Type or member is obsolete - Assert.Throws(() => selector.Select(entityType.FindProperty("Random"), entityType)).Message); -#pragma warning restore CS0618 // Type or member is obsolete - } - [ConditionalFact] public void Returns_null_for_unsupported_combinations_with_Try_method() { @@ -210,23 +137,13 @@ public override bool GeneratesTemporaryValues => false; } - private static object CreateAndUseFactory(IProperty property, bool useTry = true) + private static object CreateAndUseFactory(IProperty property) { var model = BuildModel(); var selector = InMemoryTestHelpers.Instance.CreateContextServices(model).GetRequiredService(); - ValueGenerator generator; - if (useTry) - { - selector.TrySelect(property, property.DeclaringType, out generator); - } - else - { -#pragma warning disable CS0618 // Type or member is obsolete - generator = selector.Select(property, property.DeclaringType); -#pragma warning restore CS0618 // Type or member is obsolete - } + selector.TrySelect(property, property.DeclaringType, out var generator); return generator!.Next(null!); }