diff --git a/src/EFCore.Relational/Metadata/Internal/CheckConstraint.cs b/src/EFCore.Relational/Metadata/Internal/CheckConstraint.cs index 7965038920d..92716622a4c 100644 --- a/src/EFCore.Relational/Metadata/Internal/CheckConstraint.cs +++ b/src/EFCore.Relational/Metadata/Internal/CheckConstraint.cs @@ -423,7 +423,6 @@ public override string ToString() /// 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] public virtual DebugView DebugView => new( () => ((ICheckConstraint)this).ToDebugString(), diff --git a/src/EFCore.Relational/Metadata/Internal/StoreStoredProcedure.cs b/src/EFCore.Relational/Metadata/Internal/StoreStoredProcedure.cs index 9b035aa3e97..f8edfff45a8 100644 --- a/src/EFCore.Relational/Metadata/Internal/StoreStoredProcedure.cs +++ b/src/EFCore.Relational/Metadata/Internal/StoreStoredProcedure.cs @@ -171,7 +171,6 @@ public override string ToString() /// 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] public virtual DebugView DebugView => new( () => ((IStoreStoredProcedure)this).ToDebugString(), diff --git a/src/EFCore.Relational/Metadata/Internal/StoreStoredProcedureParameter.cs b/src/EFCore.Relational/Metadata/Internal/StoreStoredProcedureParameter.cs index 3191ee0955b..3d99b99e158 100644 --- a/src/EFCore.Relational/Metadata/Internal/StoreStoredProcedureParameter.cs +++ b/src/EFCore.Relational/Metadata/Internal/StoreStoredProcedureParameter.cs @@ -84,7 +84,6 @@ public override string ToString() /// 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] public virtual DebugView DebugView => new( () => ((IStoreStoredProcedureParameter)this).ToDebugString(), diff --git a/src/EFCore.Relational/Metadata/Internal/StoreStoredProcedureResultColumn.cs b/src/EFCore.Relational/Metadata/Internal/StoreStoredProcedureResultColumn.cs index b3e0684261f..05b5910ffa8 100644 --- a/src/EFCore.Relational/Metadata/Internal/StoreStoredProcedureResultColumn.cs +++ b/src/EFCore.Relational/Metadata/Internal/StoreStoredProcedureResultColumn.cs @@ -72,7 +72,6 @@ public override string ToString() /// 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] public virtual DebugView DebugView => new( () => ((IStoreStoredProcedureResultColumn)this).ToDebugString(), diff --git a/src/EFCore.Relational/Metadata/Internal/StoreStoredProcedureReturnValue.cs b/src/EFCore.Relational/Metadata/Internal/StoreStoredProcedureReturnValue.cs index 27b6e1702b1..86d9bafbb1b 100644 --- a/src/EFCore.Relational/Metadata/Internal/StoreStoredProcedureReturnValue.cs +++ b/src/EFCore.Relational/Metadata/Internal/StoreStoredProcedureReturnValue.cs @@ -61,7 +61,6 @@ public override string ToString() /// 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] public virtual DebugView DebugView => new( () => ((IStoreStoredProcedureReturnValue)this).ToDebugString(), diff --git a/src/EFCore.Relational/Metadata/Internal/StoredProcedure.cs b/src/EFCore.Relational/Metadata/Internal/StoredProcedure.cs index d3457298a15..57d52f5a6c4 100644 --- a/src/EFCore.Relational/Metadata/Internal/StoredProcedure.cs +++ b/src/EFCore.Relational/Metadata/Internal/StoredProcedure.cs @@ -690,7 +690,6 @@ public override string ToString() /// 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] public virtual DebugView DebugView => new( () => ((IStoredProcedure)this).ToDebugString(), diff --git a/src/EFCore.Relational/Metadata/Internal/StoredProcedureMapping.cs b/src/EFCore.Relational/Metadata/Internal/StoredProcedureMapping.cs index 86b2ad4fea7..5bf640f219c 100644 --- a/src/EFCore.Relational/Metadata/Internal/StoredProcedureMapping.cs +++ b/src/EFCore.Relational/Metadata/Internal/StoredProcedureMapping.cs @@ -86,7 +86,6 @@ public override string ToString() /// 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] public virtual DebugView DebugView => new( () => ((IStoredProcedureMapping)this).ToDebugString(), diff --git a/src/EFCore.Relational/Metadata/Internal/StoredProcedureParameter.cs b/src/EFCore.Relational/Metadata/Internal/StoredProcedureParameter.cs index 24a701fd9f6..eb4f288abb4 100644 --- a/src/EFCore.Relational/Metadata/Internal/StoredProcedureParameter.cs +++ b/src/EFCore.Relational/Metadata/Internal/StoredProcedureParameter.cs @@ -266,7 +266,6 @@ public override string ToString() /// 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] public virtual DebugView DebugView => new( () => ((IStoredProcedureParameter)this).ToDebugString(), diff --git a/src/EFCore.Relational/Metadata/Internal/StoredProcedureParameterMapping.cs b/src/EFCore.Relational/Metadata/Internal/StoredProcedureParameterMapping.cs index 15f1ba67344..3a07090020e 100644 --- a/src/EFCore.Relational/Metadata/Internal/StoredProcedureParameterMapping.cs +++ b/src/EFCore.Relational/Metadata/Internal/StoredProcedureParameterMapping.cs @@ -68,7 +68,6 @@ public override string ToString() /// 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] public virtual DebugView DebugView => new( () => ((IStoredProcedureParameterMapping)this).ToDebugString(), diff --git a/src/EFCore.Relational/Metadata/Internal/StoredProcedureResultColumn.cs b/src/EFCore.Relational/Metadata/Internal/StoredProcedureResultColumn.cs index bd633a0fb41..ae9bcce195f 100644 --- a/src/EFCore.Relational/Metadata/Internal/StoredProcedureResultColumn.cs +++ b/src/EFCore.Relational/Metadata/Internal/StoredProcedureResultColumn.cs @@ -184,7 +184,6 @@ public override string ToString() /// 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] public virtual DebugView DebugView => new( () => ((IStoredProcedureResultColumn)this).ToDebugString(), diff --git a/src/EFCore.Relational/Metadata/Internal/StoredProcedureResultColumnMapping.cs b/src/EFCore.Relational/Metadata/Internal/StoredProcedureResultColumnMapping.cs index dfaea6244da..51b40790312 100644 --- a/src/EFCore.Relational/Metadata/Internal/StoredProcedureResultColumnMapping.cs +++ b/src/EFCore.Relational/Metadata/Internal/StoredProcedureResultColumnMapping.cs @@ -68,7 +68,6 @@ public override string ToString() /// 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] public virtual DebugView DebugView => new( () => ((IStoredProcedureResultColumnMapping)this).ToDebugString(), diff --git a/src/EFCore.Relational/Storage/ValueConversion/RelationalConverterMappingHints.cs b/src/EFCore.Relational/Storage/ValueConversion/RelationalConverterMappingHints.cs index 70bb0489ff5..ea677e5b762 100644 --- a/src/EFCore.Relational/Storage/ValueConversion/RelationalConverterMappingHints.cs +++ b/src/EFCore.Relational/Storage/ValueConversion/RelationalConverterMappingHints.cs @@ -30,7 +30,7 @@ public RelationalConverterMappingHints( int? scale = null, bool? unicode = null, bool? fixedLength = null, - Func? valueGeneratorFactory = null, + Func? valueGeneratorFactory = null, DbType? dbType = null) : base(size, precision, scale, unicode, valueGeneratorFactory) { @@ -71,7 +71,9 @@ 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,7 +86,9 @@ public override ConverterMappingHints Override(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/Metadata/RuntimeSkipNavigation.cs b/src/EFCore/Metadata/RuntimeSkipNavigation.cs index baa73917429..c9ec4110675 100644 --- a/src/EFCore/Metadata/RuntimeSkipNavigation.cs +++ b/src/EFCore/Metadata/RuntimeSkipNavigation.cs @@ -115,6 +115,7 @@ public override string ToString() /// 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] public virtual DebugView DebugView => new( () => ((IReadOnlySkipNavigation)this).ToDebugString(), diff --git a/src/EFCore/Storage/CoreTypeMapping.cs b/src/EFCore/Storage/CoreTypeMapping.cs index 7bf49bc0a5a..9a226491d78 100644 --- a/src/EFCore/Storage/CoreTypeMapping.cs +++ b/src/EFCore/Storage/CoreTypeMapping.cs @@ -213,8 +213,10 @@ 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 } /// @@ -242,7 +244,8 @@ public virtual ValueConverter? Converter /// An optional factory for creating a specific to use with /// this mapping. /// - public virtual Func? ValueGeneratorFactory { get; } + [Obsolete] + public virtual Func? ValueGeneratorFactory { get; } /// /// A adds custom value snapshotting and comparison for diff --git a/src/EFCore/Storage/ValueConversion/ConverterMappingHints.cs b/src/EFCore/Storage/ValueConversion/ConverterMappingHints.cs index 1ecb1aea39d..9076f4c0eb3 100644 --- a/src/EFCore/Storage/ValueConversion/ConverterMappingHints.cs +++ b/src/EFCore/Storage/ValueConversion/ConverterMappingHints.cs @@ -28,13 +28,15 @@ public ConverterMappingHints( int? precision = null, int? scale = null, bool? unicode = null, - Func? valueGeneratorFactory = null) + Func? valueGeneratorFactory = 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 } /// @@ -54,7 +56,9 @@ public virtual ConverterMappingHints With(ConverterMappingHints? hints) 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.Override(this); /// @@ -74,7 +78,9 @@ public virtual ConverterMappingHints Override(ConverterMappingHints? hints) 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 : hints.With(this); /// @@ -101,5 +107,6 @@ public virtual ConverterMappingHints Override(ConverterMappingHints? hints) /// An optional factory for creating a specific to use for model /// values when this converter is being used. /// - public virtual Func? ValueGeneratorFactory { get; } + [Obsolete] + public virtual Func? ValueGeneratorFactory { get; } } diff --git a/src/EFCore/ValueGeneration/ValueGeneratorSelector.cs b/src/EFCore/ValueGeneration/ValueGeneratorSelector.cs index d3c1af43f7a..207d3672ad1 100644 --- a/src/EFCore/ValueGeneration/ValueGeneratorSelector.cs +++ b/src/EFCore/ValueGeneration/ValueGeneratorSelector.cs @@ -58,16 +58,22 @@ public ValueGeneratorSelector(ValueGeneratorSelectorDependencies dependencies) public virtual ValueGenerator Select(IProperty property, ITypeBase typeBase) => Cache.GetOrAdd(property, typeBase, (p, t) => CreateFromFactory(p, t) ?? Create(p, t)); - private static ValueGenerator? CreateFromFactory(IProperty property, ITypeBase entityType) + private static ValueGenerator? CreateFromFactory(IProperty property, ITypeBase structuralType) { var factory = property.GetValueGeneratorFactory(); if (factory == null) { var mapping = property.GetTypeMapping(); - factory = mapping.ValueGeneratorFactory; +#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, entityType); + return factory?.Invoke(property, structuralType); } ///