diff --git a/src/EFCore.Analyzers/InternalUsageDiagnosticAnalyzer.cs b/src/EFCore.Analyzers/InternalUsageDiagnosticAnalyzer.cs
index 3ece2c37c2f..f5b5479f441 100644
--- a/src/EFCore.Analyzers/InternalUsageDiagnosticAnalyzer.cs
+++ b/src/EFCore.Analyzers/InternalUsageDiagnosticAnalyzer.cs
@@ -27,7 +27,7 @@ public const string MessageFormat
private static readonly int EFLen = "EntityFrameworkCore".Length;
private static readonly DiagnosticDescriptor _descriptor
- = new DiagnosticDescriptor(
+ = new(
Id,
title: DefaultTitle,
messageFormat: MessageFormat,
diff --git a/src/EFCore.Cosmos/Diagnostics/CosmosEventId.cs b/src/EFCore.Cosmos/Diagnostics/CosmosEventId.cs
index 54eaf77798c..3c3285225bc 100644
--- a/src/EFCore.Cosmos/Diagnostics/CosmosEventId.cs
+++ b/src/EFCore.Cosmos/Diagnostics/CosmosEventId.cs
@@ -43,7 +43,7 @@ private enum Id
///
///
public static readonly EventId ExecutingSqlQuery
- = new EventId((int)Id.ExecutingSqlQuery, _commandPrefix + Id.ExecutingSqlQuery);
+ = new((int)Id.ExecutingSqlQuery, _commandPrefix + Id.ExecutingSqlQuery);
///
///
@@ -54,6 +54,6 @@ public static readonly EventId ExecutingSqlQuery
///
///
public static readonly EventId ExecutingReadItem
- = new EventId((int)Id.ExecutingReadItem, _commandPrefix + Id.ExecutingReadItem);
+ = new((int)Id.ExecutingReadItem, _commandPrefix + Id.ExecutingReadItem);
}
}
diff --git a/src/EFCore.Cosmos/Infrastructure/Internal/CosmosDbOptionExtension.cs b/src/EFCore.Cosmos/Infrastructure/Internal/CosmosDbOptionExtension.cs
index 05a95eebf07..b9c896fef08 100644
--- a/src/EFCore.Cosmos/Infrastructure/Internal/CosmosDbOptionExtension.cs
+++ b/src/EFCore.Cosmos/Infrastructure/Internal/CosmosDbOptionExtension.cs
@@ -496,7 +496,7 @@ public virtual CosmosOptionsExtension WithExecutionStrategyFactory(
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
protected virtual CosmosOptionsExtension Clone()
- => new CosmosOptionsExtension(this);
+ => new(this);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosMemberTranslatorProvider.cs b/src/EFCore.Cosmos/Query/Internal/CosmosMemberTranslatorProvider.cs
index 8cc45199323..21ddaa19197 100644
--- a/src/EFCore.Cosmos/Query/Internal/CosmosMemberTranslatorProvider.cs
+++ b/src/EFCore.Cosmos/Query/Internal/CosmosMemberTranslatorProvider.cs
@@ -21,8 +21,8 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
///
public class CosmosMemberTranslatorProvider : IMemberTranslatorProvider
{
- private readonly List _plugins = new List();
- private readonly List _translators = new List();
+ private readonly List _plugins = new();
+ private readonly List _translators = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosMethodCallTranslatorProvider.cs b/src/EFCore.Cosmos/Query/Internal/CosmosMethodCallTranslatorProvider.cs
index d30e1128f69..7f987f81e4d 100644
--- a/src/EFCore.Cosmos/Query/Internal/CosmosMethodCallTranslatorProvider.cs
+++ b/src/EFCore.Cosmos/Query/Internal/CosmosMethodCallTranslatorProvider.cs
@@ -21,8 +21,8 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
///
public class CosmosMethodCallTranslatorProvider : IMethodCallTranslatorProvider
{
- private readonly List _plugins = new List();
- private readonly List _translators = new List();
+ private readonly List _plugins = new();
+ private readonly List _translators = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosProjectionBindingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosProjectionBindingExpressionVisitor.cs
index 215634b9061..383281a2f1f 100644
--- a/src/EFCore.Cosmos/Query/Internal/CosmosProjectionBindingExpressionVisitor.cs
+++ b/src/EFCore.Cosmos/Query/Internal/CosmosProjectionBindingExpressionVisitor.cs
@@ -38,13 +38,13 @@ private static readonly MethodInfo _getParameterValueMethodInfo
private readonly IDictionary _projectionMapping
= new Dictionary();
- private readonly Stack _projectionMembers = new Stack();
+ private readonly Stack _projectionMembers = new();
private readonly IDictionary _collectionShaperMapping
= new Dictionary();
private readonly Stack _includedNavigations
- = new Stack();
+ = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitor.cs
index 4f82ac800b9..52c940ede16 100644
--- a/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitor.cs
+++ b/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitor.cs
@@ -249,7 +249,7 @@ protected override ShapedQueryExpression CreateShapedQueryExpression(IEntityType
}
private ShapedQueryExpression CreateShapedQueryExpression(Expression queryExpression, IEntityType entityType)
- => new ShapedQueryExpression(
+ => new(
queryExpression,
new EntityShaperExpression(
entityType,
diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitorBase.cs b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitorBase.cs
index ff784e3d7d4..06eb627c3eb 100644
--- a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitorBase.cs
+++ b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitorBase.cs
@@ -62,7 +62,7 @@ private readonly IDictionary _ordinalParameterBindings
= new Dictionary();
private List _pendingIncludes
- = new List();
+ = new();
private static readonly MethodInfo _toObjectMethodInfo
= typeof(CosmosProjectionBindingRemovingExpressionVisitorBase)
diff --git a/src/EFCore.Cosmos/Query/Internal/InExpression.cs b/src/EFCore.Cosmos/Query/Internal/InExpression.cs
index f5989440248..12d93ddd85c 100644
--- a/src/EFCore.Cosmos/Query/Internal/InExpression.cs
+++ b/src/EFCore.Cosmos/Query/Internal/InExpression.cs
@@ -83,7 +83,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public virtual InExpression Negate()
- => new InExpression(Item, !IsNegated, Values, TypeMapping!);
+ => new(Item, !IsNegated, Values, TypeMapping!);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Cosmos/Query/Internal/QuerySqlGenerator.cs b/src/EFCore.Cosmos/Query/Internal/QuerySqlGenerator.cs
index 6d3ef445c6b..0b78961d59e 100644
--- a/src/EFCore.Cosmos/Query/Internal/QuerySqlGenerator.cs
+++ b/src/EFCore.Cosmos/Query/Internal/QuerySqlGenerator.cs
@@ -24,7 +24,7 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
///
public class QuerySqlGenerator : SqlExpressionVisitor
{
- private readonly StringBuilder _sqlBuilder = new StringBuilder();
+ private readonly StringBuilder _sqlBuilder = new();
private IReadOnlyDictionary _parameterValues;
private List _sqlParameters;
private bool _useValueProjection;
diff --git a/src/EFCore.Cosmos/Query/Internal/QuerySqlGeneratorFactory.cs b/src/EFCore.Cosmos/Query/Internal/QuerySqlGeneratorFactory.cs
index 0dd00893e0e..8f30a6fb0da 100644
--- a/src/EFCore.Cosmos/Query/Internal/QuerySqlGeneratorFactory.cs
+++ b/src/EFCore.Cosmos/Query/Internal/QuerySqlGeneratorFactory.cs
@@ -20,6 +20,6 @@ public class QuerySqlGeneratorFactory : IQuerySqlGeneratorFactory
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public virtual QuerySqlGenerator Create()
- => new QuerySqlGenerator();
+ => new();
}
}
diff --git a/src/EFCore.Cosmos/Query/Internal/SelectExpression.cs b/src/EFCore.Cosmos/Query/Internal/SelectExpression.cs
index d0faf8783cd..a1893b654f0 100644
--- a/src/EFCore.Cosmos/Query/Internal/SelectExpression.cs
+++ b/src/EFCore.Cosmos/Query/Internal/SelectExpression.cs
@@ -25,8 +25,8 @@ public class SelectExpression : Expression
private const string RootAlias = "c";
private IDictionary _projectionMapping = new Dictionary();
- private readonly List _projection = new List();
- private readonly List _orderings = new List();
+ private readonly List _projection = new();
+ private readonly List _orderings = new();
private ValueConverter _partitionKeyValueConverter;
private Expression _partitionKeyValue;
diff --git a/src/EFCore.Cosmos/Query/Internal/SqlExpressionFactory.cs b/src/EFCore.Cosmos/Query/Internal/SqlExpressionFactory.cs
index ebc047a9239..c1faef078ea 100644
--- a/src/EFCore.Cosmos/Query/Internal/SqlExpressionFactory.cs
+++ b/src/EFCore.Cosmos/Query/Internal/SqlExpressionFactory.cs
@@ -509,7 +509,7 @@ public virtual InExpression In(SqlExpression item, SqlExpression values, bool ne
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public virtual SqlConstantExpression Constant(object value, CoreTypeMapping typeMapping = null)
- => new SqlConstantExpression(Expression.Constant(value), typeMapping);
+ => new(Expression.Constant(value), typeMapping);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Cosmos/Query/Internal/SqlFunctionExpression.cs b/src/EFCore.Cosmos/Query/Internal/SqlFunctionExpression.cs
index 93bccd2ffff..97c681712a6 100644
--- a/src/EFCore.Cosmos/Query/Internal/SqlFunctionExpression.cs
+++ b/src/EFCore.Cosmos/Query/Internal/SqlFunctionExpression.cs
@@ -89,11 +89,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public virtual SqlFunctionExpression ApplyTypeMapping([CanBeNull] CoreTypeMapping? typeMapping)
- => new SqlFunctionExpression(
- Name,
- Arguments,
- Type,
- typeMapping ?? TypeMapping);
+ => new(Name, Arguments, Type, typeMapping ?? TypeMapping);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Cosmos/Storage/Internal/CosmosConcurrencyToken.cs b/src/EFCore.Cosmos/Storage/Internal/CosmosConcurrencyToken.cs
index e85762cd256..b9d05e5d050 100644
--- a/src/EFCore.Cosmos/Storage/Internal/CosmosConcurrencyToken.cs
+++ b/src/EFCore.Cosmos/Storage/Internal/CosmosConcurrencyToken.cs
@@ -25,7 +25,7 @@ private CosmosConcurrencyToken(string value, CosmosConcurrencyMode mode)
/// 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 static CosmosConcurrencyToken None { get; } = new CosmosConcurrencyToken(null, CosmosConcurrencyMode.None);
+ public static CosmosConcurrencyToken None { get; } = new(null, CosmosConcurrencyMode.None);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -50,7 +50,7 @@ private CosmosConcurrencyToken(string value, CosmosConcurrencyMode mode)
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public static CosmosConcurrencyToken IfMatch([CanBeNull] string value)
- => new CosmosConcurrencyToken(value, CosmosConcurrencyMode.IfMatch);
+ => new(value, CosmosConcurrencyMode.IfMatch);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -59,6 +59,6 @@ public static CosmosConcurrencyToken IfMatch([CanBeNull] string value)
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public static CosmosConcurrencyToken IfNotMatch([CanBeNull] string value)
- => new CosmosConcurrencyToken(value, CosmosConcurrencyMode.IfNoneMatch);
+ => new(value, CosmosConcurrencyMode.IfNoneMatch);
}
}
diff --git a/src/EFCore.Design/Scaffolding/Internal/CSharpEntityTypeGenerator.cs b/src/EFCore.Design/Scaffolding/Internal/CSharpEntityTypeGenerator.cs
index 17ce96528d6..7de5931edc5 100644
--- a/src/EFCore.Design/Scaffolding/Internal/CSharpEntityTypeGenerator.cs
+++ b/src/EFCore.Design/Scaffolding/Internal/CSharpEntityTypeGenerator.cs
@@ -510,7 +510,7 @@ private void GenerateComment(string comment)
private sealed class AttributeWriter
{
private readonly string _attributeName;
- private readonly List _parameters = new List();
+ private readonly List _parameters = new();
public AttributeWriter([NotNull] string attributeName)
{
diff --git a/src/EFCore.Design/Scaffolding/Internal/CSharpNamer.cs b/src/EFCore.Design/Scaffolding/Internal/CSharpNamer.cs
index c484a36f7ca..da894b257b1 100644
--- a/src/EFCore.Design/Scaffolding/Internal/CSharpNamer.cs
+++ b/src/EFCore.Design/Scaffolding/Internal/CSharpNamer.cs
@@ -26,7 +26,7 @@ public class CSharpNamer
/// 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.
///
- protected readonly Dictionary NameCache = new Dictionary();
+ protected readonly Dictionary NameCache = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Design/Scaffolding/Internal/CSharpUniqueNamer.cs b/src/EFCore.Design/Scaffolding/Internal/CSharpUniqueNamer.cs
index b05c7a2d1d0..525f7eb4d33 100644
--- a/src/EFCore.Design/Scaffolding/Internal/CSharpUniqueNamer.cs
+++ b/src/EFCore.Design/Scaffolding/Internal/CSharpUniqueNamer.cs
@@ -15,7 +15,7 @@ namespace Microsoft.EntityFrameworkCore.Scaffolding.Internal
///
public class CSharpUniqueNamer : CSharpNamer
{
- private readonly HashSet _usedNames = new HashSet(StringComparer.OrdinalIgnoreCase);
+ private readonly HashSet _usedNames = new(StringComparer.OrdinalIgnoreCase);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Design/Scaffolding/Internal/CSharpUtilities.cs b/src/EFCore.Design/Scaffolding/Internal/CSharpUtilities.cs
index d662b5789b7..35f6561666a 100644
--- a/src/EFCore.Design/Scaffolding/Internal/CSharpUtilities.cs
+++ b/src/EFCore.Design/Scaffolding/Internal/CSharpUtilities.cs
@@ -18,7 +18,7 @@ namespace Microsoft.EntityFrameworkCore.Scaffolding.Internal
///
public class CSharpUtilities : ICSharpUtilities
{
- private static readonly HashSet _cSharpKeywords = new HashSet
+ private static readonly HashSet _cSharpKeywords = new()
{
"abstract",
"as",
@@ -100,7 +100,7 @@ public class CSharpUtilities : ICSharpUtilities
};
private static readonly Regex _invalidCharsRegex
- = new Regex(
+ = new(
@"[^\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Nl}\p{Mn}\p{Mc}\p{Cf}\p{Pc}\p{Lm}]",
default,
TimeSpan.FromMilliseconds(1000.0));
diff --git a/src/EFCore.Design/Scaffolding/Internal/RelationalScaffoldingModelFactory.cs b/src/EFCore.Design/Scaffolding/Internal/RelationalScaffoldingModelFactory.cs
index 63276031ba1..aeb096c05e1 100644
--- a/src/EFCore.Design/Scaffolding/Internal/RelationalScaffoldingModelFactory.cs
+++ b/src/EFCore.Design/Scaffolding/Internal/RelationalScaffoldingModelFactory.cs
@@ -36,10 +36,10 @@ public class RelationalScaffoldingModelFactory : IScaffoldingModelFactory
private readonly ICandidateNamingService _candidateNamingService;
private Dictionary> _columnNamers;
private ModelReverseEngineerOptions _options;
- private readonly DatabaseTable _nullTable = new DatabaseTable();
+ private readonly DatabaseTable _nullTable = new();
private CSharpUniqueNamer _tableNamer;
private CSharpUniqueNamer _dbSetNamer;
- private readonly HashSet _unmappedColumns = new HashSet();
+ private readonly HashSet _unmappedColumns = new();
private readonly IPluralizer _pluralizer;
private readonly ICSharpUtilities _cSharpUtilities;
private readonly IScaffoldingTypeMapper _scaffoldingTypeMapper;
@@ -929,7 +929,7 @@ protected virtual void AddNavigationProperties([NotNull] IMutableForeignKey fore
// Stores the names of the EntityType itself and its Properties, but does not include any Navigation Properties
private readonly Dictionary> _entityTypeAndPropertyIdentifiers =
- new Dictionary>();
+ new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.InMemory/Diagnostics/InMemoryEventId.cs b/src/EFCore.InMemory/Diagnostics/InMemoryEventId.cs
index 376e0d32704..efe7b10f9c7 100644
--- a/src/EFCore.InMemory/Diagnostics/InMemoryEventId.cs
+++ b/src/EFCore.InMemory/Diagnostics/InMemoryEventId.cs
@@ -33,7 +33,7 @@ private enum Id
private static readonly string _transactionPrefix = DbLoggerCategory.Database.Transaction.Name + ".";
private static EventId MakeTransactionId(Id id)
- => new EventId((int)id, _transactionPrefix + id);
+ => new((int)id, _transactionPrefix + id);
///
///
@@ -51,7 +51,7 @@ private static EventId MakeTransactionId(Id id)
private static readonly string _updatePrefix = DbLoggerCategory.Update.Name + ".";
private static EventId MakeUpdateId(Id id)
- => new EventId((int)id, _updatePrefix + id);
+ => new((int)id, _updatePrefix + id);
///
///
diff --git a/src/EFCore.InMemory/Infrastructure/Internal/InMemoryOptionsExtension.cs b/src/EFCore.InMemory/Infrastructure/Internal/InMemoryOptionsExtension.cs
index bbab0b73fa8..e7c6b9dcd14 100644
--- a/src/EFCore.InMemory/Infrastructure/Internal/InMemoryOptionsExtension.cs
+++ b/src/EFCore.InMemory/Infrastructure/Internal/InMemoryOptionsExtension.cs
@@ -62,7 +62,7 @@ public virtual DbContextOptionsExtensionInfo Info
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
protected virtual InMemoryOptionsExtension Clone()
- => new InMemoryOptionsExtension(this);
+ => new(this);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.InMemory/Query/Internal/InMemoryProjectionBindingExpressionVisitor.cs b/src/EFCore.InMemory/Query/Internal/InMemoryProjectionBindingExpressionVisitor.cs
index 518146a309e..74611da58be 100644
--- a/src/EFCore.InMemory/Query/Internal/InMemoryProjectionBindingExpressionVisitor.cs
+++ b/src/EFCore.InMemory/Query/Internal/InMemoryProjectionBindingExpressionVisitor.cs
@@ -35,7 +35,7 @@ public class InMemoryProjectionBindingExpressionVisitor : ExpressionVisitor
private readonly IDictionary _projectionMapping
= new Dictionary();
- private readonly Stack _projectionMembers = new Stack();
+ private readonly Stack _projectionMembers = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -502,7 +502,7 @@ private CollectionShaperExpression AddCollectionProjection(
ShapedQueryExpression subquery,
INavigationBase? navigation,
Type elementType)
- => new CollectionShaperExpression(
+ => new(
new ProjectionBindingExpression(
_queryExpression,
_queryExpression.AddSubqueryProjection(
diff --git a/src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.cs b/src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.cs
index 5135d2411a1..0ba21736128 100644
--- a/src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.cs
+++ b/src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.cs
@@ -35,7 +35,7 @@ private static readonly ConstructorInfo _valueBufferConstructor
private static readonly PropertyInfo _valueBufferCountMemberInfo
= typeof(ValueBuffer).GetRequiredProperty(nameof(ValueBuffer.Count));
- private readonly List _valueBufferSlots = new List();
+ private readonly List _valueBufferSlots = new();
private readonly IDictionary> _entityProjectionCache
= new Dictionary>();
diff --git a/src/EFCore.InMemory/Query/Internal/ShaperExpressionProcessingExpressionVisitor.cs b/src/EFCore.InMemory/Query/Internal/ShaperExpressionProcessingExpressionVisitor.cs
index 822294fa19a..ecf886590f6 100644
--- a/src/EFCore.InMemory/Query/Internal/ShaperExpressionProcessingExpressionVisitor.cs
+++ b/src/EFCore.InMemory/Query/Internal/ShaperExpressionProcessingExpressionVisitor.cs
@@ -23,8 +23,8 @@ public class ShaperExpressionProcessingExpressionVisitor : ExpressionVisitor
private readonly ParameterExpression _valueBufferParameter;
private readonly IDictionary _mapping = new Dictionary();
- private readonly List _variables = new List();
- private readonly List _expressions = new List();
+ private readonly List _variables = new();
+ private readonly List _expressions = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.InMemory/Storage/Internal/InMemoryStore.cs b/src/EFCore.InMemory/Storage/Internal/InMemoryStore.cs
index bb080437f13..d8e180b338a 100644
--- a/src/EFCore.InMemory/Storage/Internal/InMemoryStore.cs
+++ b/src/EFCore.InMemory/Storage/Internal/InMemoryStore.cs
@@ -24,7 +24,7 @@ public class InMemoryStore : IInMemoryStore
private readonly IInMemoryTableFactory _tableFactory;
private readonly bool _useNameMatching;
- private readonly object _lock = new object();
+ private readonly object _lock = new();
private Dictionary _tables;
@@ -120,7 +120,7 @@ public virtual bool Clear()
}
private static Dictionary CreateTables()
- => new Dictionary();
+ => new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.InMemory/Storage/Internal/InMemoryTableFactory.cs b/src/EFCore.InMemory/Storage/Internal/InMemoryTableFactory.cs
index 2eb055a56c6..ceee6ddeb24 100644
--- a/src/EFCore.InMemory/Storage/Internal/InMemoryTableFactory.cs
+++ b/src/EFCore.InMemory/Storage/Internal/InMemoryTableFactory.cs
@@ -26,7 +26,7 @@ public class InMemoryTableFactory : IInMemoryTableFactory
private readonly bool _nullabilityCheckEnabled;
private readonly ConcurrentDictionary<(IEntityType EntityType, IInMemoryTable BaseTable), Func> _factories
- = new ConcurrentDictionary<(IEntityType, IInMemoryTable), Func>();
+ = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.InMemory/Storage/Internal/InMemoryTransactionManager.cs b/src/EFCore.InMemory/Storage/Internal/InMemoryTransactionManager.cs
index c44a52932b1..0f2cc1fab69 100644
--- a/src/EFCore.InMemory/Storage/Internal/InMemoryTransactionManager.cs
+++ b/src/EFCore.InMemory/Storage/Internal/InMemoryTransactionManager.cs
@@ -29,7 +29,7 @@ namespace Microsoft.EntityFrameworkCore.InMemory.Storage.Internal
///
public class InMemoryTransactionManager : IDbContextTransactionManager, ITransactionEnlistmentManager
{
- private static readonly InMemoryTransaction _stubTransaction = new InMemoryTransaction();
+ private static readonly InMemoryTransaction _stubTransaction = new();
private readonly IDiagnosticsLogger _logger;
diff --git a/src/EFCore.Proxies/Proxies/Internal/ProxiesOptionsExtension.cs b/src/EFCore.Proxies/Proxies/Internal/ProxiesOptionsExtension.cs
index a3a86a54599..35d3a6c9f06 100644
--- a/src/EFCore.Proxies/Proxies/Internal/ProxiesOptionsExtension.cs
+++ b/src/EFCore.Proxies/Proxies/Internal/ProxiesOptionsExtension.cs
@@ -65,7 +65,7 @@ public virtual DbContextOptionsExtensionInfo Info
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
protected virtual ProxiesOptionsExtension Clone()
- => new ProxiesOptionsExtension(this);
+ => new(this);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Proxies/Proxies/Internal/ProxyFactory.cs b/src/EFCore.Proxies/Proxies/Internal/ProxyFactory.cs
index aae68a69ba8..a962a1a0492 100644
--- a/src/EFCore.Proxies/Proxies/Internal/ProxyFactory.cs
+++ b/src/EFCore.Proxies/Proxies/Internal/ProxyFactory.cs
@@ -25,7 +25,7 @@ public class ProxyFactory : IProxyFactory
private static readonly Type _notifyPropertyChangedInterface = typeof(INotifyPropertyChanged);
private static readonly Type _notifyPropertyChangingInterface = typeof(INotifyPropertyChanging);
- private readonly ProxyGenerator _generator = new ProxyGenerator();
+ private readonly ProxyGenerator _generator = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Relational/Design/MethodCallCodeFragment.cs b/src/EFCore.Relational/Design/MethodCallCodeFragment.cs
index 3060783f61a..5573850a7f7 100644
--- a/src/EFCore.Relational/Design/MethodCallCodeFragment.cs
+++ b/src/EFCore.Relational/Design/MethodCallCodeFragment.cs
@@ -79,9 +79,6 @@ public virtual MethodCallCodeFragment Chain([NotNull] string method, [NotNull] p
/// The next method.
/// A new fragment representing the method chain.
public virtual MethodCallCodeFragment Chain([NotNull] MethodCallCodeFragment call)
- => new MethodCallCodeFragment(
- Method,
- _arguments.ToArray(),
- ChainedCall?.Chain(call) ?? call);
+ => new(Method, _arguments.ToArray(), ChainedCall?.Chain(call) ?? call);
}
}
diff --git a/src/EFCore.Relational/Diagnostics/DbCommandInterceptor.cs b/src/EFCore.Relational/Diagnostics/DbCommandInterceptor.cs
index 5308b31b925..7003b93541a 100644
--- a/src/EFCore.Relational/Diagnostics/DbCommandInterceptor.cs
+++ b/src/EFCore.Relational/Diagnostics/DbCommandInterceptor.cs
@@ -158,7 +158,7 @@ public virtual ValueTask> ReaderExecutingAsync(
CommandEventData eventData,
InterceptionResult result,
CancellationToken cancellationToken = default)
- => new ValueTask>(result);
+ => new(result);
///
/// Called just before EF intends to call .
@@ -185,7 +185,7 @@ public virtual ValueTask> ScalarExecutingAsync(
CommandEventData eventData,
InterceptionResult result,
CancellationToken cancellationToken = default)
- => new ValueTask>(result);
+ => new(result);
///
/// Called just before EF intends to call .
@@ -212,7 +212,7 @@ public virtual ValueTask> NonQueryExecutingAsync(
CommandEventData eventData,
InterceptionResult result,
CancellationToken cancellationToken = default)
- => new ValueTask>(result);
+ => new(result);
///
///
@@ -319,7 +319,7 @@ public virtual ValueTask ReaderExecutedAsync(
CommandExecutedEventData eventData,
DbDataReader result,
CancellationToken cancellationToken = default)
- => new ValueTask(result);
+ => new(result);
///
///
@@ -348,7 +348,7 @@ public virtual ValueTask ScalarExecutedAsync(
CommandExecutedEventData eventData,
object result,
CancellationToken cancellationToken = default)
- => new ValueTask(result);
+ => new(result);
///
///
@@ -377,7 +377,7 @@ public virtual ValueTask NonQueryExecutedAsync(
CommandExecutedEventData eventData,
int result,
CancellationToken cancellationToken = default)
- => new ValueTask(result);
+ => new(result);
///
/// Called when execution of a command has failed with an exception.
diff --git a/src/EFCore.Relational/Diagnostics/DbConnectionInterceptor.cs b/src/EFCore.Relational/Diagnostics/DbConnectionInterceptor.cs
index 719b95ac2be..dac80201213 100644
--- a/src/EFCore.Relational/Diagnostics/DbConnectionInterceptor.cs
+++ b/src/EFCore.Relational/Diagnostics/DbConnectionInterceptor.cs
@@ -65,7 +65,7 @@ public virtual ValueTask ConnectionOpeningAsync(
ConnectionEventData eventData,
InterceptionResult result,
CancellationToken cancellationToken = default)
- => new ValueTask(result);
+ => new(result);
///
/// Called just after EF has called .
@@ -136,7 +136,7 @@ public virtual ValueTask ConnectionClosingAsync(
DbConnection connection,
ConnectionEventData eventData,
InterceptionResult result)
- => new ValueTask(result);
+ => new(result);
///
/// Called just after EF has called in an async context.
diff --git a/src/EFCore.Relational/Diagnostics/DbTransactionInterceptor.cs b/src/EFCore.Relational/Diagnostics/DbTransactionInterceptor.cs
index 03fa13b2fd3..654a23fd94a 100644
--- a/src/EFCore.Relational/Diagnostics/DbTransactionInterceptor.cs
+++ b/src/EFCore.Relational/Diagnostics/DbTransactionInterceptor.cs
@@ -93,7 +93,7 @@ public virtual ValueTask> TransactionStartingA
TransactionStartingEventData eventData,
InterceptionResult result,
CancellationToken cancellationToken = default)
- => new ValueTask>(result);
+ => new(result);
///
///
@@ -125,7 +125,7 @@ public virtual ValueTask TransactionStartedAsync(
TransactionEndEventData eventData,
DbTransaction result,
CancellationToken cancellationToken = default)
- => new ValueTask(result);
+ => new(result);
///
///
@@ -173,7 +173,7 @@ public virtual ValueTask TransactionUsedAsync(
TransactionEventData eventData,
DbTransaction result,
CancellationToken cancellationToken = default)
- => new ValueTask(result);
+ => new(result);
///
/// Called just before EF intends to call .
@@ -236,7 +236,7 @@ public virtual ValueTask TransactionCommittingAsync(
TransactionEventData eventData,
InterceptionResult result,
CancellationToken cancellationToken = default)
- => new ValueTask(result);
+ => new(result);
///
/// Called immediately after EF calls .
@@ -313,7 +313,7 @@ public virtual ValueTask TransactionRollingBackAsync(
TransactionEventData eventData,
InterceptionResult result,
CancellationToken cancellationToken = default)
- => new ValueTask(result);
+ => new(result);
///
/// Called immediately after EF calls .
@@ -349,7 +349,7 @@ public virtual ValueTask CreatingSavepointAsync(
TransactionEventData eventData,
InterceptionResult result,
CancellationToken cancellationToken = default)
- => new ValueTask(result);
+ => new(result);
///
public virtual Task CreatedSavepointAsync(
@@ -378,7 +378,7 @@ public virtual ValueTask RollingBackToSavepointAsync(
TransactionEventData eventData,
InterceptionResult result,
CancellationToken cancellationToken = default)
- => new ValueTask(result);
+ => new(result);
///
public virtual Task RolledBackToSavepointAsync(
@@ -407,7 +407,7 @@ public virtual ValueTask ReleasingSavepointAsync(
TransactionEventData eventData,
InterceptionResult result,
CancellationToken cancellationToken = default)
- => new ValueTask(result);
+ => new(result);
///
public virtual Task ReleasedSavepointAsync(
diff --git a/src/EFCore.Relational/Diagnostics/RelationalEventId.cs b/src/EFCore.Relational/Diagnostics/RelationalEventId.cs
index 6c5d41210fb..e9bf0ceb6ff 100644
--- a/src/EFCore.Relational/Diagnostics/RelationalEventId.cs
+++ b/src/EFCore.Relational/Diagnostics/RelationalEventId.cs
@@ -98,7 +98,7 @@ private enum Id
private static readonly string _connectionPrefix = DbLoggerCategory.Database.Connection.Name + ".";
private static EventId MakeConnectionId(Id id)
- => new EventId((int)id, _connectionPrefix + id);
+ => new((int)id, _connectionPrefix + id);
///
///
@@ -168,7 +168,7 @@ private static EventId MakeConnectionId(Id id)
private static readonly string _sqlPrefix = DbLoggerCategory.Database.Command.Name + ".";
private static EventId MakeCommandId(Id id)
- => new EventId((int)id, _sqlPrefix + id);
+ => new((int)id, _sqlPrefix + id);
///
///
@@ -238,7 +238,7 @@ private static EventId MakeCommandId(Id id)
private static readonly string _transactionPrefix = DbLoggerCategory.Database.Transaction.Name + ".";
private static EventId MakeTransactionId(Id id)
- => new EventId((int)id, _transactionPrefix + id);
+ => new((int)id, _transactionPrefix + id);
///
///
@@ -490,7 +490,7 @@ private static EventId MakeTransactionId(Id id)
private static readonly string _migrationsPrefix = DbLoggerCategory.Migrations.Name + ".";
private static EventId MakeMigrationsId(Id id)
- => new EventId((int)id, _migrationsPrefix + id);
+ => new((int)id, _migrationsPrefix + id);
///
///
@@ -599,7 +599,7 @@ private static EventId MakeMigrationsId(Id id)
private static readonly string _queryPrefix = DbLoggerCategory.Query.Name + ".";
private static EventId MakeQueryId(Id id)
- => new EventId((int)id, _queryPrefix + id);
+ => new((int)id, _queryPrefix + id);
///
///
@@ -640,7 +640,7 @@ private static EventId MakeQueryId(Id id)
private static readonly string _validationPrefix = DbLoggerCategory.Model.Validation.Name + ".";
private static EventId MakeValidationId(Id id)
- => new EventId((int)id, _validationPrefix + id);
+ => new((int)id, _validationPrefix + id);
///
///
@@ -726,7 +726,7 @@ private static EventId MakeValidationId(Id id)
private static readonly string _updatePrefix = DbLoggerCategory.Update.Name + ".";
private static EventId MakeUpdateId(Id id)
- => new EventId((int)id, _updatePrefix + id);
+ => new((int)id, _updatePrefix + id);
///
///
diff --git a/src/EFCore.Relational/Extensions/RelationalModelBuilderExtensions.cs b/src/EFCore.Relational/Extensions/RelationalModelBuilderExtensions.cs
index a781fe2b9ee..72f8fa66938 100644
--- a/src/EFCore.Relational/Extensions/RelationalModelBuilderExtensions.cs
+++ b/src/EFCore.Relational/Extensions/RelationalModelBuilderExtensions.cs
@@ -30,7 +30,7 @@ public static SequenceBuilder HasSequence(
[NotNull] this ModelBuilder modelBuilder,
[NotNull] string name,
[CanBeNull] string schema = null)
- => new SequenceBuilder(
+ => new(
HasSequence(
Check.NotNull(modelBuilder, nameof(modelBuilder)).Model,
name,
diff --git a/src/EFCore.Relational/Metadata/Builders/DbFunctionBuilderBase.cs b/src/EFCore.Relational/Metadata/Builders/DbFunctionBuilderBase.cs
index 550088a0b64..e9527f38c42 100644
--- a/src/EFCore.Relational/Metadata/Builders/DbFunctionBuilderBase.cs
+++ b/src/EFCore.Relational/Metadata/Builders/DbFunctionBuilderBase.cs
@@ -94,7 +94,7 @@ public virtual DbFunctionBuilderBase IsBuiltIn(bool builtIn = true)
/// The parameter name.
/// The builder to use for further parameter configuration.
public virtual DbFunctionParameterBuilder HasParameter([NotNull] string name)
- => new DbFunctionParameterBuilder(Builder.HasParameter(name, ConfigurationSource.Explicit).Metadata);
+ => new(Builder.HasParameter(name, ConfigurationSource.Explicit).Metadata);
#region Hidden System.Object members
diff --git a/src/EFCore.Relational/Metadata/Internal/ColumnBase.cs b/src/EFCore.Relational/Metadata/Internal/ColumnBase.cs
index b2d8a174fc8..2d259fa85f8 100644
--- a/src/EFCore.Relational/Metadata/Internal/ColumnBase.cs
+++ b/src/EFCore.Relational/Metadata/Internal/ColumnBase.cs
@@ -51,7 +51,7 @@ public ColumnBase([NotNull] string name, [NotNull] string type, [NotNull] TableB
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public virtual SortedSet PropertyMappings { get; }
- = new SortedSet(ColumnMappingBaseComparer.Instance);
+ = new(ColumnMappingBaseComparer.Instance);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Relational/Metadata/Internal/ColumnListComparer.cs b/src/EFCore.Relational/Metadata/Internal/ColumnListComparer.cs
index 6f40d4c3c90..cc69e088f7a 100644
--- a/src/EFCore.Relational/Metadata/Internal/ColumnListComparer.cs
+++ b/src/EFCore.Relational/Metadata/Internal/ColumnListComparer.cs
@@ -23,7 +23,7 @@ public sealed class ColumnListComparer : IComparer>, IEqu
/// 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 static readonly ColumnListComparer Instance = new ColumnListComparer();
+ public static readonly ColumnListComparer Instance = new();
private ColumnListComparer()
{
diff --git a/src/EFCore.Relational/Metadata/Internal/ColumnMappingBaseComparer.cs b/src/EFCore.Relational/Metadata/Internal/ColumnMappingBaseComparer.cs
index a88e0c7365b..5548a99064c 100644
--- a/src/EFCore.Relational/Metadata/Internal/ColumnMappingBaseComparer.cs
+++ b/src/EFCore.Relational/Metadata/Internal/ColumnMappingBaseComparer.cs
@@ -26,7 +26,7 @@ private ColumnMappingBaseComparer()
/// 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 static readonly ColumnMappingBaseComparer Instance = new ColumnMappingBaseComparer();
+ public static readonly ColumnMappingBaseComparer Instance = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Relational/Metadata/Internal/ForeignKeyConstraint.cs b/src/EFCore.Relational/Metadata/Internal/ForeignKeyConstraint.cs
index c1e91a86391..c8a2979833d 100644
--- a/src/EFCore.Relational/Metadata/Internal/ForeignKeyConstraint.cs
+++ b/src/EFCore.Relational/Metadata/Internal/ForeignKeyConstraint.cs
@@ -49,7 +49,7 @@ public ForeignKeyConstraint(
/// 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 SortedSet MappedForeignKeys { get; } = new SortedSet(ForeignKeyComparer.Instance);
+ public virtual SortedSet MappedForeignKeys { get; } = new(ForeignKeyComparer.Instance);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Relational/Metadata/Internal/ForeignKeyConstraintComparer.cs b/src/EFCore.Relational/Metadata/Internal/ForeignKeyConstraintComparer.cs
index ce4c6c3d82b..598e0cfedd2 100644
--- a/src/EFCore.Relational/Metadata/Internal/ForeignKeyConstraintComparer.cs
+++ b/src/EFCore.Relational/Metadata/Internal/ForeignKeyConstraintComparer.cs
@@ -27,7 +27,7 @@ private ForeignKeyConstraintComparer()
/// 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 static readonly ForeignKeyConstraintComparer Instance = new ForeignKeyConstraintComparer();
+ public static readonly ForeignKeyConstraintComparer Instance = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Relational/Metadata/Internal/NamedListComparer.cs b/src/EFCore.Relational/Metadata/Internal/NamedListComparer.cs
index a6ceb958375..40f7c5edf88 100644
--- a/src/EFCore.Relational/Metadata/Internal/NamedListComparer.cs
+++ b/src/EFCore.Relational/Metadata/Internal/NamedListComparer.cs
@@ -24,7 +24,7 @@ public sealed class NamedListComparer : IComparer<(string, string?, IReadOnlyLis
/// 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 static readonly NamedListComparer Instance = new NamedListComparer();
+ public static readonly NamedListComparer Instance = new();
private NamedListComparer()
{
diff --git a/src/EFCore.Relational/Metadata/Internal/RelationalModel.cs b/src/EFCore.Relational/Metadata/Internal/RelationalModel.cs
index 3f512964b20..e7936e59292 100644
--- a/src/EFCore.Relational/Metadata/Internal/RelationalModel.cs
+++ b/src/EFCore.Relational/Metadata/Internal/RelationalModel.cs
@@ -43,7 +43,7 @@ public RelationalModel([NotNull] IModel model)
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public virtual SortedDictionary DefaultTables { get; }
- = new SortedDictionary();
+ = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -52,7 +52,7 @@ public RelationalModel([NotNull] IModel model)
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public virtual SortedDictionary<(string, string?), Table> Tables { get; }
- = new SortedDictionary<(string, string?), Table>();
+ = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -61,7 +61,7 @@ public RelationalModel([NotNull] IModel model)
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public virtual SortedDictionary<(string, string?), View> Views { get; }
- = new SortedDictionary<(string, string?), View>();
+ = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -70,7 +70,7 @@ public RelationalModel([NotNull] IModel model)
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public virtual SortedDictionary Queries { get; }
- = new SortedDictionary();
+ = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -79,7 +79,7 @@ public RelationalModel([NotNull] IModel model)
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public virtual SortedDictionary<(string, string?, IReadOnlyList), StoreFunction> Functions { get; }
- = new SortedDictionary<(string, string?, IReadOnlyList), StoreFunction>(NamedListComparer.Instance);
+ = new(NamedListComparer.Instance);
///
public virtual ITable? FindTable(string name, string? schema)
@@ -1139,7 +1139,7 @@ public static ReferentialAction ToReferentialAction(DeleteBehavior deleteBehavio
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public virtual DebugView DebugView
- => new DebugView(
+ => new(
() => this.ToDebugString(MetadataDebugStringOptions.ShortDefault),
() => this.ToDebugString(MetadataDebugStringOptions.LongDefault));
diff --git a/src/EFCore.Relational/Metadata/Internal/Table.cs b/src/EFCore.Relational/Metadata/Internal/Table.cs
index fa984e07178..edc34402d57 100644
--- a/src/EFCore.Relational/Metadata/Internal/Table.cs
+++ b/src/EFCore.Relational/Metadata/Internal/Table.cs
@@ -41,7 +41,7 @@ public Table([NotNull] string name, [CanBeNull] string? schema, [NotNull] Relati
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public virtual SortedDictionary ForeignKeyConstraints { get; }
- = new SortedDictionary();
+ = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -99,7 +99,7 @@ public virtual UniqueConstraint? PrimaryKey
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public virtual SortedDictionary UniqueConstraints { get; }
- = new SortedDictionary();
+ = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -121,7 +121,7 @@ public virtual UniqueConstraint? PrimaryKey
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public virtual SortedDictionary Indexes { get; }
- = new SortedDictionary();
+ = new();
///
public virtual bool IsExcludedFromMigrations { get; set; }
diff --git a/src/EFCore.Relational/Metadata/Internal/TableBase.cs b/src/EFCore.Relational/Metadata/Internal/TableBase.cs
index cb62f905fdf..67aa1f3d86b 100644
--- a/src/EFCore.Relational/Metadata/Internal/TableBase.cs
+++ b/src/EFCore.Relational/Metadata/Internal/TableBase.cs
@@ -57,7 +57,7 @@ public TableBase([NotNull] string name, [CanBeNull] string? schema, [NotNull] Re
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public virtual SortedSet EntityTypeMappings { get; }
- = new SortedSet(TableMappingBaseComparer.Instance);
+ = new(TableMappingBaseComparer.Instance);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -66,7 +66,7 @@ public TableBase([NotNull] string name, [CanBeNull] string? schema, [NotNull] Re
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public virtual SortedDictionary Columns { get; [param: NotNull] protected set; }
- = new SortedDictionary(StringComparer.Ordinal);
+ = new(StringComparer.Ordinal);
///
public virtual IColumnBase? FindColumn(string name)
diff --git a/src/EFCore.Relational/Metadata/Internal/TableIndex.cs b/src/EFCore.Relational/Metadata/Internal/TableIndex.cs
index b727f3fe436..e53fe194560 100644
--- a/src/EFCore.Relational/Metadata/Internal/TableIndex.cs
+++ b/src/EFCore.Relational/Metadata/Internal/TableIndex.cs
@@ -46,7 +46,7 @@ public TableIndex(
/// 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 SortedSet MappedIndexes { get; } = new SortedSet(IndexComparer.Instance);
+ public virtual SortedSet MappedIndexes { get; } = new(IndexComparer.Instance);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Relational/Metadata/Internal/TableIndexComparer.cs b/src/EFCore.Relational/Metadata/Internal/TableIndexComparer.cs
index b9459d4ba60..719984d83a8 100644
--- a/src/EFCore.Relational/Metadata/Internal/TableIndexComparer.cs
+++ b/src/EFCore.Relational/Metadata/Internal/TableIndexComparer.cs
@@ -27,7 +27,7 @@ private TableIndexComparer()
/// 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 static readonly TableIndexComparer Instance = new TableIndexComparer();
+ public static readonly TableIndexComparer Instance = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Relational/Metadata/Internal/TableMappingBase.cs b/src/EFCore.Relational/Metadata/Internal/TableMappingBase.cs
index 88d4b29d556..96f21ad2422 100644
--- a/src/EFCore.Relational/Metadata/Internal/TableMappingBase.cs
+++ b/src/EFCore.Relational/Metadata/Internal/TableMappingBase.cs
@@ -47,7 +47,7 @@ public TableMappingBase(
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public virtual SortedSet ColumnMappings { get; }
- = new SortedSet(ColumnMappingBaseComparer.Instance);
+ = new(ColumnMappingBaseComparer.Instance);
///
public virtual bool IncludesDerivedTypes { get; }
diff --git a/src/EFCore.Relational/Metadata/Internal/TableMappingBaseComparer.cs b/src/EFCore.Relational/Metadata/Internal/TableMappingBaseComparer.cs
index 0327a0b3d3b..8b2852c60df 100644
--- a/src/EFCore.Relational/Metadata/Internal/TableMappingBaseComparer.cs
+++ b/src/EFCore.Relational/Metadata/Internal/TableMappingBaseComparer.cs
@@ -28,7 +28,7 @@ private TableMappingBaseComparer()
/// 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 static readonly TableMappingBaseComparer Instance = new TableMappingBaseComparer();
+ public static readonly TableMappingBaseComparer Instance = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Relational/Metadata/Internal/UniqueConstraint.cs b/src/EFCore.Relational/Metadata/Internal/UniqueConstraint.cs
index 8cb6fa0e8ab..71fd4112139 100644
--- a/src/EFCore.Relational/Metadata/Internal/UniqueConstraint.cs
+++ b/src/EFCore.Relational/Metadata/Internal/UniqueConstraint.cs
@@ -42,7 +42,7 @@ public UniqueConstraint(
/// 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 SortedSet MappedKeys { get; } = new SortedSet(KeyComparer.Instance);
+ public virtual SortedSet MappedKeys { get; } = new(KeyComparer.Instance);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Relational/Metadata/Internal/UniqueConstraintComparer.cs b/src/EFCore.Relational/Metadata/Internal/UniqueConstraintComparer.cs
index 27fef6bf89e..d149113b1c6 100644
--- a/src/EFCore.Relational/Metadata/Internal/UniqueConstraintComparer.cs
+++ b/src/EFCore.Relational/Metadata/Internal/UniqueConstraintComparer.cs
@@ -27,7 +27,7 @@ private UniqueConstraintComparer()
/// 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 static readonly UniqueConstraintComparer Instance = new UniqueConstraintComparer();
+ public static readonly UniqueConstraintComparer Instance = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Relational/Migrations/Internal/MigrationsIdGenerator.cs b/src/EFCore.Relational/Migrations/Internal/MigrationsIdGenerator.cs
index 18bf7464f9d..a0db9e89755 100644
--- a/src/EFCore.Relational/Migrations/Internal/MigrationsIdGenerator.cs
+++ b/src/EFCore.Relational/Migrations/Internal/MigrationsIdGenerator.cs
@@ -26,7 +26,7 @@ public class MigrationsIdGenerator : IMigrationsIdGenerator
private const string Format = "yyyyMMddHHmmss";
private DateTime _lastTimestamp = DateTime.MinValue;
- private readonly object _lock = new object();
+ private readonly object _lock = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs b/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs
index d0f81edd566..ce498519967 100644
--- a/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs
+++ b/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs
@@ -69,7 +69,7 @@ public class MigrationsModelDiffer : IMigrationsModelDiffer
private IUpdateAdapter _targetUpdateAdapter;
private readonly Dictionary _sourceSharedIdentityEntryMaps =
- new Dictionary();
+ new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -868,7 +868,7 @@ private PropertyInfoEqualityComparer()
{
}
- public static readonly PropertyInfoEqualityComparer Instance = new PropertyInfoEqualityComparer();
+ public static readonly PropertyInfoEqualityComparer Instance = new();
public bool Equals(PropertyInfo x, PropertyInfo y)
=> x.IsSameAs(y);
@@ -2493,8 +2493,8 @@ public static IProperty[] GetMappedProperties([NotNull] ITable table, [NotNull]
private sealed class EntryMapping
{
- public HashSet SourceEntries { get; } = new HashSet();
- public HashSet TargetEntries { get; } = new HashSet();
+ public HashSet SourceEntries { get; } = new();
+ public HashSet TargetEntries { get; } = new();
public bool RecreateRow { get; set; }
}
@@ -2503,7 +2503,7 @@ private sealed class SharedIdentityMap
private readonly IUpdateAdapter _updateAdapter;
private readonly Dictionary _entryValueMap
- = new Dictionary();
+ = new();
public SharedIdentityMap(IUpdateAdapter updateAdapter)
{
diff --git a/src/EFCore.Relational/Migrations/MigrationBuilder.cs b/src/EFCore.Relational/Migrations/MigrationBuilder.cs
index bf88847f000..270986040c3 100644
--- a/src/EFCore.Relational/Migrations/MigrationBuilder.cs
+++ b/src/EFCore.Relational/Migrations/MigrationBuilder.cs
@@ -35,7 +35,7 @@ public MigrationBuilder([CanBeNull] string activeProvider)
///
/// The list of s being built.
///
- public virtual List Operations { get; } = new List();
+ public virtual List Operations { get; } = new();
///
/// Builds an to add a new column to a table.
diff --git a/src/EFCore.Relational/Migrations/MigrationCommandListBuilder.cs b/src/EFCore.Relational/Migrations/MigrationCommandListBuilder.cs
index abb2a65d002..763bfcb70f1 100644
--- a/src/EFCore.Relational/Migrations/MigrationCommandListBuilder.cs
+++ b/src/EFCore.Relational/Migrations/MigrationCommandListBuilder.cs
@@ -15,7 +15,7 @@ namespace Microsoft.EntityFrameworkCore.Migrations
///
public class MigrationCommandListBuilder
{
- private readonly List _commands = new List();
+ private readonly List _commands = new();
private readonly MigrationsSqlGeneratorDependencies _dependencies;
private IRelationalCommandBuilder _commandBuilder;
diff --git a/src/EFCore.Relational/Migrations/Operations/CreateTableOperation.cs b/src/EFCore.Relational/Migrations/Operations/CreateTableOperation.cs
index af8c9d8674b..f14d7405e71 100644
--- a/src/EFCore.Relational/Migrations/Operations/CreateTableOperation.cs
+++ b/src/EFCore.Relational/Migrations/Operations/CreateTableOperation.cs
@@ -21,21 +21,21 @@ public class CreateTableOperation : TableOperation
///
/// An ordered list of for adding columns to the table.
///
- public virtual List Columns { get; } = new List();
+ public virtual List Columns { get; } = new();
///
/// A list of for creating foreign key constraints in the table.
///
- public virtual List ForeignKeys { get; } = new List();
+ public virtual List ForeignKeys { get; } = new();
///
/// A list of for creating unique constraints in the table.
///
- public virtual List UniqueConstraints { get; } = new List();
+ public virtual List UniqueConstraints { get; } = new();
///
/// A list of for creating check constraints in the table.
///
- public virtual List CheckConstraints { get; } = new List();
+ public virtual List CheckConstraints { get; } = new();
}
}
diff --git a/src/EFCore.Relational/Query/Internal/QuerySqlGeneratorFactory.cs b/src/EFCore.Relational/Query/Internal/QuerySqlGeneratorFactory.cs
index 6411cd37e0d..c3a0d3f62ec 100644
--- a/src/EFCore.Relational/Query/Internal/QuerySqlGeneratorFactory.cs
+++ b/src/EFCore.Relational/Query/Internal/QuerySqlGeneratorFactory.cs
@@ -43,6 +43,6 @@ public QuerySqlGeneratorFactory([NotNull] QuerySqlGeneratorDependencies dependen
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public virtual QuerySqlGenerator Create()
- => new QuerySqlGenerator(_dependencies);
+ => new(_dependencies);
}
}
diff --git a/src/EFCore.Relational/Query/Internal/RelationalCommandCache.cs b/src/EFCore.Relational/Query/Internal/RelationalCommandCache.cs
index 9b4cba950d5..67dfcd80851 100644
--- a/src/EFCore.Relational/Query/Internal/RelationalCommandCache.cs
+++ b/src/EFCore.Relational/Query/Internal/RelationalCommandCache.cs
@@ -23,7 +23,7 @@ namespace Microsoft.EntityFrameworkCore.Query.Internal
public class RelationalCommandCache : IPrintableExpression
{
private static readonly ConcurrentDictionary _locks
- = new ConcurrentDictionary();
+ = new();
private readonly IMemoryCache _memoryCache;
private readonly IQuerySqlGeneratorFactory _querySqlGeneratorFactory;
diff --git a/src/EFCore.Relational/Query/Internal/RelationalParameterBasedSqlProcessorFactory.cs b/src/EFCore.Relational/Query/Internal/RelationalParameterBasedSqlProcessorFactory.cs
index adeff040d9a..3ebce2d9d1e 100644
--- a/src/EFCore.Relational/Query/Internal/RelationalParameterBasedSqlProcessorFactory.cs
+++ b/src/EFCore.Relational/Query/Internal/RelationalParameterBasedSqlProcessorFactory.cs
@@ -47,6 +47,6 @@ public RelationalParameterBasedSqlProcessorFactory(
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public virtual RelationalParameterBasedSqlProcessor Create(bool useRelationalNulls)
- => new RelationalParameterBasedSqlProcessor(_dependencies, useRelationalNulls);
+ => new(_dependencies, useRelationalNulls);
}
}
diff --git a/src/EFCore.Relational/Query/Internal/RelationalProjectionBindingExpressionVisitor.cs b/src/EFCore.Relational/Query/Internal/RelationalProjectionBindingExpressionVisitor.cs
index 576a410dacb..b451a261887 100644
--- a/src/EFCore.Relational/Query/Internal/RelationalProjectionBindingExpressionVisitor.cs
+++ b/src/EFCore.Relational/Query/Internal/RelationalProjectionBindingExpressionVisitor.cs
@@ -42,7 +42,7 @@ private static readonly MethodInfo _getParameterValueMethodInfo
private readonly IDictionary _projectionMapping
= new Dictionary();
- private readonly Stack _projectionMembers = new Stack();
+ private readonly Stack _projectionMembers = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Relational/Query/Internal/SqlExpressionSimplifyingExpressionVisitor.cs b/src/EFCore.Relational/Query/Internal/SqlExpressionSimplifyingExpressionVisitor.cs
index c9658136d27..3b539fbd934 100644
--- a/src/EFCore.Relational/Query/Internal/SqlExpressionSimplifyingExpressionVisitor.cs
+++ b/src/EFCore.Relational/Query/Internal/SqlExpressionSimplifyingExpressionVisitor.cs
@@ -313,7 +313,7 @@ private Expression SimplifySqlBinary(SqlBinaryExpression sqlBinaryExpression)
}
private List ConstructCollection(object left, object right)
- => new List { left, right };
+ => new() { left, right };
private List AddToCollection(IEnumerable collection, object newElement)
{
diff --git a/src/EFCore.Relational/Query/QuerySqlGenerator.cs b/src/EFCore.Relational/Query/QuerySqlGenerator.cs
index 8366335dfbb..6fc7f95f401 100644
--- a/src/EFCore.Relational/Query/QuerySqlGenerator.cs
+++ b/src/EFCore.Relational/Query/QuerySqlGenerator.cs
@@ -31,7 +31,7 @@ public class QuerySqlGenerator : SqlExpressionVisitor
private readonly ISqlGenerationHelper _sqlGenerationHelper;
private IRelationalCommandBuilder _relationalCommandBuilder;
- private static readonly Dictionary _operatorMap = new Dictionary
+ private static readonly Dictionary _operatorMap = new()
{
{ ExpressionType.Equal, " = " },
{ ExpressionType.NotEqual, " <> " },
diff --git a/src/EFCore.Relational/Query/RelationalMemberTranslatorProvider.cs b/src/EFCore.Relational/Query/RelationalMemberTranslatorProvider.cs
index 89e92a68ab7..d7e4466c672 100644
--- a/src/EFCore.Relational/Query/RelationalMemberTranslatorProvider.cs
+++ b/src/EFCore.Relational/Query/RelationalMemberTranslatorProvider.cs
@@ -30,8 +30,8 @@ namespace Microsoft.EntityFrameworkCore.Query
///
public class RelationalMemberTranslatorProvider : IMemberTranslatorProvider
{
- private readonly List _plugins = new List();
- private readonly List _translators = new List();
+ private readonly List _plugins = new();
+ private readonly List _translators = new();
///
/// Creates a new instance of the class.
diff --git a/src/EFCore.Relational/Query/RelationalMethodCallTranslatorProvider.cs b/src/EFCore.Relational/Query/RelationalMethodCallTranslatorProvider.cs
index 5c4547c9afd..8da0da16126 100644
--- a/src/EFCore.Relational/Query/RelationalMethodCallTranslatorProvider.cs
+++ b/src/EFCore.Relational/Query/RelationalMethodCallTranslatorProvider.cs
@@ -31,8 +31,8 @@ namespace Microsoft.EntityFrameworkCore.Query
///
public class RelationalMethodCallTranslatorProvider : IMethodCallTranslatorProvider
{
- private readonly List _plugins = new List();
- private readonly List _translators = new List();
+ private readonly List _plugins = new();
+ private readonly List _translators = new();
private readonly ISqlExpressionFactory _sqlExpressionFactory;
///
diff --git a/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs
index b7617837b82..b573062cbbd 100644
--- a/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs
+++ b/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs
@@ -175,7 +175,7 @@ protected override ShapedQueryExpression CreateShapedQueryExpression(IEntityType
}
private static ShapedQueryExpression CreateShapedQueryExpression(IEntityType entityType, SelectExpression selectExpression)
- => new ShapedQueryExpression(
+ => new(
selectExpression,
new RelationalEntityShaperExpression(
entityType,
diff --git a/src/EFCore.Relational/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs b/src/EFCore.Relational/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs
index 09a58fc00fc..d984a9418e5 100644
--- a/src/EFCore.Relational/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs
+++ b/src/EFCore.Relational/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs
@@ -107,12 +107,12 @@ private static readonly MethodInfo _collectionAccessorAddMethodInfo
private readonly IDictionary _variableShaperMapping = new Dictionary();
// There are always entity variables to avoid materializing same entity twice
- private readonly List _variables = new List();
+ private readonly List _variables = new();
- private readonly List _expressions = new List();
+ private readonly List _expressions = new();
// IncludeExpressions are added at the end in case they are using ValuesArray
- private readonly List _includeExpressions = new List();
+ private readonly List _includeExpressions = new();
// If there is collection shaper then we need to construct ValuesArray to store values temporarily in ResultContext
private List? _collectionPopulatingExpressions;
diff --git a/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs b/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs
index 8067109eb22..926821b9293 100644
--- a/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs
+++ b/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs
@@ -638,7 +638,7 @@ static Expression RemapLambda(GroupingElementExpression groupingElement, LambdaE
}
selector = _sqlExpressionFactory.Case(
- new List { new CaseWhenClause(groupingElement.Predicate, selector) },
+ new List { new(groupingElement.Predicate, selector) },
elseResult: null);
}
diff --git a/src/EFCore.Relational/Query/SqlExpressionFactory.cs b/src/EFCore.Relational/Query/SqlExpressionFactory.cs
index 33bc73aca1b..ea71e6ef89c 100644
--- a/src/EFCore.Relational/Query/SqlExpressionFactory.cs
+++ b/src/EFCore.Relational/Query/SqlExpressionFactory.cs
@@ -788,11 +788,11 @@ public virtual SqlFragmentExpression Fragment(string sql)
///
public virtual SqlConstantExpression Constant(object? value, RelationalTypeMapping? typeMapping = null)
- => new SqlConstantExpression(Expression.Constant(value), typeMapping);
+ => new(Expression.Constant(value), typeMapping);
///
public virtual SelectExpression Select(SqlExpression? projection)
- => new SelectExpression(projection);
+ => new(projection);
///
public virtual SelectExpression Select(IEntityType entityType)
diff --git a/src/EFCore.Relational/Query/SqlExpressions/CaseExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/CaseExpression.cs
index 898a47440c9..f47aabee4e9 100644
--- a/src/EFCore.Relational/Query/SqlExpressions/CaseExpression.cs
+++ b/src/EFCore.Relational/Query/SqlExpressions/CaseExpression.cs
@@ -23,7 +23,7 @@ namespace Microsoft.EntityFrameworkCore.Query.SqlExpressions
///
public class CaseExpression : SqlExpression
{
- private readonly List _whenClauses = new List();
+ private readonly List _whenClauses = new();
///
/// Creates a new instance of the class which represents a simple CASE expression.
diff --git a/src/EFCore.Relational/Query/SqlExpressions/ColumnExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/ColumnExpression.cs
index ba964a9aefe..114a05e1794 100644
--- a/src/EFCore.Relational/Query/SqlExpressions/ColumnExpression.cs
+++ b/src/EFCore.Relational/Query/SqlExpressions/ColumnExpression.cs
@@ -96,7 +96,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
///
/// A new expression which has property set to true.
public ColumnExpression MakeNullable()
- => new ColumnExpression(Name, Table, Type, TypeMapping!, true);
+ => new(Name, Table, Type, TypeMapping!, true);
///
protected override void Print(ExpressionPrinter expressionPrinter)
diff --git a/src/EFCore.Relational/Query/SqlExpressions/InExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/InExpression.cs
index 29b52513cae..b63564f0e2f 100644
--- a/src/EFCore.Relational/Query/SqlExpressions/InExpression.cs
+++ b/src/EFCore.Relational/Query/SqlExpressions/InExpression.cs
@@ -141,7 +141,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
///
/// An expression which is negated form of this expression.
public virtual InExpression Negate()
- => new InExpression(Item, Values, Subquery, !IsNegated, TypeMapping);
+ => new(Item, Values, Subquery, !IsNegated, TypeMapping);
///
/// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will
diff --git a/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs
index a24d20ce6ad..5593c92425d 100644
--- a/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs
+++ b/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs
@@ -36,7 +36,7 @@ namespace Microsoft.EntityFrameworkCore.Query.SqlExpressions
public sealed class SelectExpression : TableExpressionBase
{
private static readonly Dictionary _mirroredOperationMap =
- new Dictionary
+ new()
{
{ ExpressionType.Equal, ExpressionType.Equal },
{ ExpressionType.NotEqual, ExpressionType.NotEqual },
@@ -51,20 +51,20 @@ public sealed class SelectExpression : TableExpressionBase
private readonly IDictionary> _entityProjectionCache
= new Dictionary>();
- private readonly List _projection = new List();
- private readonly List _tables = new List();
- private readonly List _groupBy = new List();
- private readonly List _orderings = new List();
+ private readonly List _projection = new();
+ private readonly List _tables = new();
+ private readonly List _groupBy = new();
+ private readonly List _orderings = new();
private readonly List<(ColumnExpression Column, ValueComparer Comparer)> _identifier
- = new List<(ColumnExpression Column, ValueComparer Comparer)>();
+ = new();
private readonly List<(ColumnExpression Column, ValueComparer Comparer)> _childIdentifiers
- = new List<(ColumnExpression Column, ValueComparer Comparer)>();
+ = new();
- private readonly List _pendingCollections = new List();
+ private readonly List _pendingCollections = new();
- private List _tptLeftJoinTables = new List();
+ private List _tptLeftJoinTables = new();
private IDictionary _projectionMapping = new Dictionary();
///
@@ -317,7 +317,7 @@ private static ColumnExpression CreateColumnExpression(
ITableBase table,
TableExpressionBase tableExpression,
bool nullable)
- => new ColumnExpression(property, table.FindColumn(property)!, tableExpression, nullable);
+ => new(property, table.FindColumn(property)!, tableExpression, nullable);
///
/// Checks whether this representes a which is not composed upon.
@@ -723,7 +723,7 @@ public void ApplyDefaultIfEmpty([NotNull] ISqlExpressionFactory sqlExpressionFac
var dummySelectExpression = new SelectExpression(
alias: "empty",
- new List { new ProjectionExpression(nullSqlExpression, "empty") },
+ new List { new(nullSqlExpression, "empty") },
new List(),
new List(),
new List());
@@ -2113,7 +2113,7 @@ protected override Expression VisitExtension(Expression extensionExpression)
}
private CollectionShaperExpression Remap(CollectionShaperExpression collectionShaperExpression)
- => new CollectionShaperExpression(
+ => new(
new ProjectionBindingExpression(
_queryExpression,
((ProjectionBindingExpression)collectionShaperExpression.Projection).Index!.Value + (int)_pendingCollectionOffset!,
diff --git a/src/EFCore.Relational/Query/SqlExpressions/SqlFunctionExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/SqlFunctionExpression.cs
index 53968c488eb..716d21725ff 100644
--- a/src/EFCore.Relational/Query/SqlExpressions/SqlFunctionExpression.cs
+++ b/src/EFCore.Relational/Query/SqlExpressions/SqlFunctionExpression.cs
@@ -307,7 +307,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// A relational type mapping to apply.
/// A new expression which has supplied type mapping.
public virtual SqlFunctionExpression ApplyTypeMapping([CanBeNull] RelationalTypeMapping? typeMapping)
- => new SqlFunctionExpression(
+ => new(
Instance,
Schema,
Name,
@@ -426,7 +426,7 @@ public static SqlFunctionExpression CreateNiladic(
[NotNull] string name,
[NotNull] Type type,
[CanBeNull] RelationalTypeMapping typeMapping)
- => new SqlFunctionExpression(name, nullable: true, type, typeMapping);
+ => new(name, nullable: true, type, typeMapping);
///
/// Creates a new instance of the class.
@@ -442,7 +442,7 @@ public static SqlFunctionExpression CreateNiladic(
[NotNull] string name,
[NotNull] Type type,
[CanBeNull] RelationalTypeMapping typeMapping)
- => new SqlFunctionExpression(schema, name, nullable: true, type, typeMapping);
+ => new(schema, name, nullable: true, type, typeMapping);
///
/// Creates a new instance of the class.
@@ -458,7 +458,7 @@ public static SqlFunctionExpression CreateNiladic(
[NotNull] string name,
[NotNull] Type type,
[CanBeNull] RelationalTypeMapping typeMapping)
- => new SqlFunctionExpression(instance, name, nullable: true, instancePropagatesNullability: false, type, typeMapping);
+ => new(instance, name, nullable: true, instancePropagatesNullability: false, type, typeMapping);
///
/// Creates a new instance of the class.
@@ -476,7 +476,7 @@ public static SqlFunctionExpression Create(
[NotNull] IEnumerable arguments,
[NotNull] Type type,
[CanBeNull] RelationalTypeMapping typeMapping)
- => new SqlFunctionExpression(
+ => new(
instance,
name,
arguments,
@@ -500,8 +500,7 @@ public static SqlFunctionExpression Create(
[NotNull] IEnumerable arguments,
[NotNull] Type type,
[CanBeNull] RelationalTypeMapping typeMapping)
- => new SqlFunctionExpression(
- name, arguments, nullable: true, argumentsPropagateNullability: arguments.Select(a => false), type, typeMapping);
+ => new(name, arguments, nullable: true, argumentsPropagateNullability: arguments.Select(a => false), type, typeMapping);
///
/// Creates a new instance of the class.
@@ -519,8 +518,7 @@ public static SqlFunctionExpression Create(
[NotNull] IEnumerable arguments,
[NotNull] Type type,
[CanBeNull] RelationalTypeMapping typeMapping)
- => new SqlFunctionExpression(
- schema, name, arguments, nullable: true, argumentsPropagateNullability: arguments.Select(a => false), type, typeMapping);
+ => new(schema, name, arguments, nullable: true, argumentsPropagateNullability: arguments.Select(a => false), type, typeMapping);
#endregion
}
diff --git a/src/EFCore.Relational/Storage/ParameterNameGeneratorFactory.cs b/src/EFCore.Relational/Storage/ParameterNameGeneratorFactory.cs
index 202ae17bef0..1ed912b1c99 100644
--- a/src/EFCore.Relational/Storage/ParameterNameGeneratorFactory.cs
+++ b/src/EFCore.Relational/Storage/ParameterNameGeneratorFactory.cs
@@ -39,6 +39,6 @@ public ParameterNameGeneratorFactory([NotNull] ParameterNameGeneratorDependencie
///
/// The newly created generator.
public virtual ParameterNameGenerator Create()
- => new ParameterNameGenerator();
+ => new();
}
}
diff --git a/src/EFCore.Relational/Storage/RelationalCommand.cs b/src/EFCore.Relational/Storage/RelationalCommand.cs
index c69d4be0cab..83cc389c45a 100644
--- a/src/EFCore.Relational/Storage/RelationalCommand.cs
+++ b/src/EFCore.Relational/Storage/RelationalCommand.cs
@@ -682,11 +682,6 @@ protected virtual RelationalDataReader CreateRelationalDataReader(
[NotNull] DbDataReader reader,
Guid commandId,
[CanBeNull] IDiagnosticsLogger? logger)
- => new RelationalDataReader(
- connection,
- command,
- reader,
- commandId,
- logger);
+ => new(connection, command, reader, commandId, logger);
}
}
diff --git a/src/EFCore.Relational/Storage/RelationalCommandBuilder.cs b/src/EFCore.Relational/Storage/RelationalCommandBuilder.cs
index ac0c681d630..65d995ad9af 100644
--- a/src/EFCore.Relational/Storage/RelationalCommandBuilder.cs
+++ b/src/EFCore.Relational/Storage/RelationalCommandBuilder.cs
@@ -21,8 +21,8 @@ namespace Microsoft.EntityFrameworkCore.Storage
///
public class RelationalCommandBuilder : IRelationalCommandBuilder
{
- private readonly List _parameters = new List();
- private readonly IndentedStringBuilder _commandTextBuilder = new IndentedStringBuilder();
+ private readonly List _parameters = new();
+ private readonly IndentedStringBuilder _commandTextBuilder = new();
///
///
diff --git a/src/EFCore.Relational/Storage/RelationalConnection.cs b/src/EFCore.Relational/Storage/RelationalConnection.cs
index f039c768f98..6a95ca66f74 100644
--- a/src/EFCore.Relational/Storage/RelationalConnection.cs
+++ b/src/EFCore.Relational/Storage/RelationalConnection.cs
@@ -948,7 +948,7 @@ Task IResettableService.ResetStateAsync(CancellationToken cancellationToken)
/// The semaphore used to serialize access to this connection.
///
[Obsolete("EF Core no longer uses this semaphore. It will be removed in an upcoming release.")]
- public virtual SemaphoreSlim Semaphore { get; } = new SemaphoreSlim(1);
+ public virtual SemaphoreSlim Semaphore { get; } = new(1);
private Transaction? _enlistedTransaction;
diff --git a/src/EFCore.Relational/Storage/RelationalTransactionFactory.cs b/src/EFCore.Relational/Storage/RelationalTransactionFactory.cs
index 4694d8c9b55..0dda975825d 100644
--- a/src/EFCore.Relational/Storage/RelationalTransactionFactory.cs
+++ b/src/EFCore.Relational/Storage/RelationalTransactionFactory.cs
@@ -60,7 +60,6 @@ public virtual RelationalTransaction Create(
Guid transactionId,
IDiagnosticsLogger logger,
bool transactionOwned)
- => new RelationalTransaction(
- connection, transaction, transactionId, logger, transactionOwned, Dependencies.SqlGenerationHelper);
+ => new(connection, transaction, transactionId, logger, transactionOwned, Dependencies.SqlGenerationHelper);
}
}
diff --git a/src/EFCore.Relational/Storage/RelationalTypeMapping.cs b/src/EFCore.Relational/Storage/RelationalTypeMapping.cs
index d6d38c8589e..1bc61939d35 100644
--- a/src/EFCore.Relational/Storage/RelationalTypeMapping.cs
+++ b/src/EFCore.Relational/Storage/RelationalTypeMapping.cs
@@ -122,7 +122,7 @@ public RelationalTypeMappingParameters(
/// The mapping info containing the facets to use.
/// The new parameter object.
public RelationalTypeMappingParameters WithTypeMappingInfo(in RelationalTypeMappingInfo mappingInfo)
- => new RelationalTypeMappingParameters(
+ => new(
CoreParameters,
mappingInfo.StoreTypeName ?? StoreType,
StoreTypePostfix,
@@ -145,7 +145,7 @@ public RelationalTypeMappingParameters WithStoreTypeAndSize(
[NotNull] string storeType,
int? size,
StoreTypePostfix? storeTypePostfix = null)
- => new RelationalTypeMappingParameters(
+ => new(
CoreParameters,
storeType,
storeTypePostfix ?? StoreTypePostfix,
@@ -165,7 +165,7 @@ public RelationalTypeMappingParameters WithStoreTypeAndSize(
public RelationalTypeMappingParameters WithPrecisionAndScale(
int? precision,
int? scale)
- => new RelationalTypeMappingParameters(
+ => new(
CoreParameters,
StoreType,
StoreTypePostfix,
@@ -182,7 +182,7 @@ public RelationalTypeMappingParameters WithPrecisionAndScale(
/// The precision of data the property is configured to store, or null if no size is configured.
/// The new parameter object.
public RelationalTypeMappingParameters WithPrecision(int? precision)
- => new RelationalTypeMappingParameters(
+ => new(
CoreParameters,
StoreType,
StoreTypePostfix,
@@ -199,7 +199,7 @@ public RelationalTypeMappingParameters WithPrecision(int? precision)
/// The scale of data the property is configured to store, or null if no size is configured.
/// The new parameter object.
public RelationalTypeMappingParameters WithScale(int? scale)
- => new RelationalTypeMappingParameters(
+ => new(
CoreParameters,
StoreType,
StoreTypePostfix,
@@ -217,7 +217,7 @@ public RelationalTypeMappingParameters WithScale(int? scale)
/// The converter.
/// The new parameter object.
public RelationalTypeMappingParameters WithComposedConverter([CanBeNull] ValueConverter converter)
- => new RelationalTypeMappingParameters(
+ => new(
CoreParameters.WithComposedConverter(converter),
StoreType,
StoreTypePostfix,
diff --git a/src/EFCore.Relational/Storage/RelationalTypeMappingInfo.cs b/src/EFCore.Relational/Storage/RelationalTypeMappingInfo.cs
index 249485d9a15..7d78b204a6e 100644
--- a/src/EFCore.Relational/Storage/RelationalTypeMappingInfo.cs
+++ b/src/EFCore.Relational/Storage/RelationalTypeMappingInfo.cs
@@ -244,7 +244,7 @@ public Type? ClrType
/// The converter to apply.
/// The new mapping info.
public RelationalTypeMappingInfo WithConverter(in ValueConverterInfo converterInfo)
- => new RelationalTypeMappingInfo(this, converterInfo);
+ => new(this, converterInfo);
///
/// Compares this to another to check if they represent the same mapping.
diff --git a/src/EFCore.Relational/Storage/RelationalTypeMappingSource.cs b/src/EFCore.Relational/Storage/RelationalTypeMappingSource.cs
index 409107e5533..69c00494f6b 100644
--- a/src/EFCore.Relational/Storage/RelationalTypeMappingSource.cs
+++ b/src/EFCore.Relational/Storage/RelationalTypeMappingSource.cs
@@ -37,7 +37,7 @@ namespace Microsoft.EntityFrameworkCore.Storage
public abstract class RelationalTypeMappingSource : TypeMappingSourceBase, IRelationalTypeMappingSource
{
private readonly ConcurrentDictionary<(RelationalTypeMappingInfo, Type?, ValueConverter?), RelationalTypeMapping?> _explicitMappings
- = new ConcurrentDictionary<(RelationalTypeMappingInfo, Type?, ValueConverter?), RelationalTypeMapping?>();
+ = new();
///
/// Initializes a new instance of the this class.
diff --git a/src/EFCore.Relational/Update/Internal/KeyValueIndexFactorySource.cs b/src/EFCore.Relational/Update/Internal/KeyValueIndexFactorySource.cs
index 53dccaed70d..b245cca7afd 100644
--- a/src/EFCore.Relational/Update/Internal/KeyValueIndexFactorySource.cs
+++ b/src/EFCore.Relational/Update/Internal/KeyValueIndexFactorySource.cs
@@ -25,7 +25,7 @@ namespace Microsoft.EntityFrameworkCore.Update.Internal
public class KeyValueIndexFactorySource : IKeyValueIndexFactorySource
{
private readonly ConcurrentDictionary _factories
- = new ConcurrentDictionary();
+ = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Relational/Update/Internal/SharedTableEntryMap.cs b/src/EFCore.Relational/Update/Internal/SharedTableEntryMap.cs
index ea0d658dd1a..6623662197e 100644
--- a/src/EFCore.Relational/Update/Internal/SharedTableEntryMap.cs
+++ b/src/EFCore.Relational/Update/Internal/SharedTableEntryMap.cs
@@ -20,7 +20,7 @@ public class SharedTableEntryMap
private readonly ITable _table;
private readonly IUpdateAdapter _updateAdapter;
private readonly IComparer _comparer;
- private readonly Dictionary _entryValueMap = new Dictionary();
+ private readonly Dictionary _entryValueMap = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Relational/Update/ModificationCommand.cs b/src/EFCore.Relational/Update/ModificationCommand.cs
index c90a4c19101..49b9cfac127 100644
--- a/src/EFCore.Relational/Update/ModificationCommand.cs
+++ b/src/EFCore.Relational/Update/ModificationCommand.cs
@@ -28,7 +28,7 @@ public class ModificationCommand
private readonly Func _generateParameterName;
private readonly bool _sensitiveLoggingEnabled;
private readonly IComparer _comparer;
- private readonly List _entries = new List();
+ private readonly List _entries = new();
private IReadOnlyList _columnModifications;
private bool _requiresResultPropagation;
private bool _mainEntryAdded;
diff --git a/src/EFCore.Relational/Update/ReaderModificationCommandBatch.cs b/src/EFCore.Relational/Update/ReaderModificationCommandBatch.cs
index 1bb277d644f..82bbcd1154a 100644
--- a/src/EFCore.Relational/Update/ReaderModificationCommandBatch.cs
+++ b/src/EFCore.Relational/Update/ReaderModificationCommandBatch.cs
@@ -25,7 +25,7 @@ namespace Microsoft.EntityFrameworkCore.Update
///
public abstract class ReaderModificationCommandBatch : ModificationCommandBatch
{
- private readonly List _modificationCommands = new List();
+ private readonly List _modificationCommands = new();
///
/// Creates a new instance.
diff --git a/src/EFCore.Relational/ValueGeneration/Internal/TemporaryDateTimeOffsetValueGenerator.cs b/src/EFCore.Relational/ValueGeneration/Internal/TemporaryDateTimeOffsetValueGenerator.cs
index d9f93e40030..1f3c93b15de 100644
--- a/src/EFCore.Relational/ValueGeneration/Internal/TemporaryDateTimeOffsetValueGenerator.cs
+++ b/src/EFCore.Relational/ValueGeneration/Internal/TemporaryDateTimeOffsetValueGenerator.cs
@@ -24,7 +24,7 @@ public class TemporaryDateTimeOffsetValueGenerator : ValueGenerator
public override DateTimeOffset Next(EntityEntry entry)
- => new DateTimeOffset(Interlocked.Increment(ref _current), TimeSpan.Zero);
+ => new(Interlocked.Increment(ref _current), TimeSpan.Zero);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Relational/ValueGeneration/Internal/TemporaryDateTimeValueGenerator.cs b/src/EFCore.Relational/ValueGeneration/Internal/TemporaryDateTimeValueGenerator.cs
index 47ea678e9a5..3085c14fec0 100644
--- a/src/EFCore.Relational/ValueGeneration/Internal/TemporaryDateTimeValueGenerator.cs
+++ b/src/EFCore.Relational/ValueGeneration/Internal/TemporaryDateTimeValueGenerator.cs
@@ -24,7 +24,7 @@ public class TemporaryDateTimeValueGenerator : ValueGenerator
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override DateTime Next(EntityEntry entry)
- => new DateTime(Interlocked.Increment(ref _current));
+ => new(Interlocked.Increment(ref _current));
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Relational/ValueGeneration/RelationalValueGeneratorSelector.cs b/src/EFCore.Relational/ValueGeneration/RelationalValueGeneratorSelector.cs
index 9f2d598e8e7..43835c189ba 100644
--- a/src/EFCore.Relational/ValueGeneration/RelationalValueGeneratorSelector.cs
+++ b/src/EFCore.Relational/ValueGeneration/RelationalValueGeneratorSelector.cs
@@ -28,7 +28,7 @@ namespace Microsoft.EntityFrameworkCore.ValueGeneration
public class RelationalValueGeneratorSelector : ValueGeneratorSelector
{
private readonly TemporaryNumberValueGeneratorFactory _numberFactory
- = new TemporaryNumberValueGeneratorFactory();
+ = new();
///
/// Initializes a new instance of the class.
diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMemberTranslator.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMemberTranslator.cs
index d0c2caeceb3..63cbe23b5fc 100644
--- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMemberTranslator.cs
+++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMemberTranslator.cs
@@ -110,30 +110,24 @@ public SqlServerGeometryMemberTranslator(
{
var whenClauses = new List
{
- new CaseWhenClause(
- _sqlExpressionFactory.Constant("Point"), _sqlExpressionFactory.Constant(OgcGeometryType.Point)),
- new CaseWhenClause(
- _sqlExpressionFactory.Constant("LineString"), _sqlExpressionFactory.Constant(OgcGeometryType.LineString)),
- new CaseWhenClause(
- _sqlExpressionFactory.Constant("Polygon"), _sqlExpressionFactory.Constant(OgcGeometryType.Polygon)),
- new CaseWhenClause(
- _sqlExpressionFactory.Constant("MultiPoint"), _sqlExpressionFactory.Constant(OgcGeometryType.MultiPoint)),
- new CaseWhenClause(
+ new(_sqlExpressionFactory.Constant("Point"), _sqlExpressionFactory.Constant(OgcGeometryType.Point)),
+ new(_sqlExpressionFactory.Constant("LineString"), _sqlExpressionFactory.Constant(OgcGeometryType.LineString)),
+ new(_sqlExpressionFactory.Constant("Polygon"), _sqlExpressionFactory.Constant(OgcGeometryType.Polygon)),
+ new(_sqlExpressionFactory.Constant("MultiPoint"), _sqlExpressionFactory.Constant(OgcGeometryType.MultiPoint)),
+ new(
_sqlExpressionFactory.Constant("MultiLineString"),
_sqlExpressionFactory.Constant(OgcGeometryType.MultiLineString)),
- new CaseWhenClause(
- _sqlExpressionFactory.Constant("MultiPolygon"),
- _sqlExpressionFactory.Constant(OgcGeometryType.MultiPolygon)),
- new CaseWhenClause(
+ new(_sqlExpressionFactory.Constant("MultiPolygon"), _sqlExpressionFactory.Constant(OgcGeometryType.MultiPolygon)),
+ new(
_sqlExpressionFactory.Constant("GeometryCollection"),
_sqlExpressionFactory.Constant(OgcGeometryType.GeometryCollection)),
- new CaseWhenClause(
+ new(
_sqlExpressionFactory.Constant("CircularString"),
_sqlExpressionFactory.Constant(OgcGeometryType.CircularString)),
- new CaseWhenClause(
+ new(
_sqlExpressionFactory.Constant("CompoundCurve"),
_sqlExpressionFactory.Constant(OgcGeometryType.CompoundCurve)),
- new CaseWhenClause(
+ new(
_sqlExpressionFactory.Constant("CurvePolygon"),
_sqlExpressionFactory.Constant(OgcGeometryType.CurvePolygon))
};
diff --git a/src/EFCore.SqlServer.NTS/Scaffolding/Internal/SqlServerNetTopologySuiteCodeGeneratorPlugin.cs b/src/EFCore.SqlServer.NTS/Scaffolding/Internal/SqlServerNetTopologySuiteCodeGeneratorPlugin.cs
index cd97fc7f83d..96d09ee9124 100644
--- a/src/EFCore.SqlServer.NTS/Scaffolding/Internal/SqlServerNetTopologySuiteCodeGeneratorPlugin.cs
+++ b/src/EFCore.SqlServer.NTS/Scaffolding/Internal/SqlServerNetTopologySuiteCodeGeneratorPlugin.cs
@@ -21,7 +21,6 @@ public class SqlServerNetTopologySuiteCodeGeneratorPlugin : ProviderCodeGenerato
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override MethodCallCodeFragment GenerateProviderOptions()
- => new MethodCallCodeFragment(
- nameof(SqlServerNetTopologySuiteDbContextOptionsBuilderExtensions.UseNetTopologySuite));
+ => new(nameof(SqlServerNetTopologySuiteDbContextOptionsBuilderExtensions.UseNetTopologySuite));
}
}
diff --git a/src/EFCore.SqlServer.NTS/Storage/Internal/SqlServerGeometryTypeMapping.cs b/src/EFCore.SqlServer.NTS/Storage/Internal/SqlServerGeometryTypeMapping.cs
index a4232ae4beb..f0e52b38f5b 100644
--- a/src/EFCore.SqlServer.NTS/Storage/Internal/SqlServerGeometryTypeMapping.cs
+++ b/src/EFCore.SqlServer.NTS/Storage/Internal/SqlServerGeometryTypeMapping.cs
@@ -171,10 +171,10 @@ protected override void ConfigureParameter(DbParameter parameter)
}
private static SqlServerBytesReader CreateReader(NtsGeometryServices services, bool isGeography)
- => new SqlServerBytesReader(services) { IsGeography = isGeography };
+ => new(services) { IsGeography = isGeography };
private static SqlServerBytesWriter CreateWriter(bool isGeography)
- => new SqlServerBytesWriter { IsGeography = isGeography };
+ => new() { IsGeography = isGeography };
private static bool IsGeography(string storeType)
=> string.Equals(storeType, "geography", StringComparison.OrdinalIgnoreCase);
diff --git a/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs b/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs
index cfbcfb13138..ee75e9981d6 100644
--- a/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs
+++ b/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs
@@ -136,7 +136,7 @@ private IReadOnlyList GenerateValueGenerationStrategy(
var increment = GetAndRemove(SqlServerAnnotationNames.IdentityIncrement) ?? 1;
return new List
{
- new MethodCallCodeFragment(
+ new(
onModel
? nameof(SqlServerModelBuilderExtensions.UseIdentityColumns)
: nameof(SqlServerPropertyBuilderExtensions.UseIdentityColumn),
@@ -153,7 +153,7 @@ private IReadOnlyList GenerateValueGenerationStrategy(
var schema = GetAndRemove(SqlServerAnnotationNames.HiLoSequenceSchema);
return new List
{
- new MethodCallCodeFragment(
+ new(
nameof(SqlServerModelBuilderExtensions.UseHiLo),
(name, schema) switch
{
@@ -166,7 +166,7 @@ private IReadOnlyList GenerateValueGenerationStrategy(
case SqlServerValueGenerationStrategy.None:
return new List
{
- new MethodCallCodeFragment(
+ new(
nameof(ModelBuilder.HasAnnotation),
SqlServerAnnotationNames.ValueGenerationStrategy,
SqlServerValueGenerationStrategy.None)
diff --git a/src/EFCore.SqlServer/Diagnostics/SqlServerEventId.cs b/src/EFCore.SqlServer/Diagnostics/SqlServerEventId.cs
index 1b02de29ab5..191f009cb42 100644
--- a/src/EFCore.SqlServer/Diagnostics/SqlServerEventId.cs
+++ b/src/EFCore.SqlServer/Diagnostics/SqlServerEventId.cs
@@ -68,7 +68,7 @@ private enum Id
private static readonly string _validationPrefix = DbLoggerCategory.Model.Validation.Name + ".";
private static EventId MakeValidationId(Id id)
- => new EventId((int)id, _validationPrefix + id);
+ => new((int)id, _validationPrefix + id);
///
///
@@ -127,7 +127,7 @@ private static EventId MakeValidationId(Id id)
private static readonly string _transactionPrefix = DbLoggerCategory.Database.Transaction.Name + ".";
private static EventId MakeTransactionId(Id id)
- => new EventId((int)id, _transactionPrefix + id);
+ => new((int)id, _transactionPrefix + id);
///
///
@@ -143,7 +143,7 @@ private static EventId MakeTransactionId(Id id)
private static readonly string _scaffoldingPrefix = DbLoggerCategory.Scaffolding.Name + ".";
private static EventId MakeScaffoldingId(Id id)
- => new EventId((int)id, _scaffoldingPrefix + id);
+ => new((int)id, _scaffoldingPrefix + id);
///
/// A column was found.
diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerConvertTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerConvertTranslator.cs
index 3f0ef0402bc..690177166c3 100644
--- a/src/EFCore.SqlServer/Query/Internal/SqlServerConvertTranslator.cs
+++ b/src/EFCore.SqlServer/Query/Internal/SqlServerConvertTranslator.cs
@@ -23,7 +23,7 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal
///
public class SqlServerConvertTranslator : IMethodCallTranslator
{
- private static readonly Dictionary _typeMapping = new Dictionary
+ private static readonly Dictionary _typeMapping = new()
{
[nameof(Convert.ToBoolean)] = "bit",
[nameof(Convert.ToByte)] = "tinyint",
@@ -35,7 +35,7 @@ public class SqlServerConvertTranslator : IMethodCallTranslator
[nameof(Convert.ToString)] = "nvarchar(max)"
};
- private static readonly List _supportedTypes = new List
+ private static readonly List _supportedTypes = new()
{
typeof(bool),
typeof(byte),
diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerDataLengthFunctionTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerDataLengthFunctionTranslator.cs
index a533fdeb921..14e5e622c04 100644
--- a/src/EFCore.SqlServer/Query/Internal/SqlServerDataLengthFunctionTranslator.cs
+++ b/src/EFCore.SqlServer/Query/Internal/SqlServerDataLengthFunctionTranslator.cs
@@ -23,7 +23,7 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal
///
public class SqlServerDataLengthFunctionTranslator : IMethodCallTranslator
{
- private static readonly List _longReturningTypes = new List
+ private static readonly List _longReturningTypes = new()
{
"nvarchar(max)",
"varchar(max)",
@@ -31,7 +31,7 @@ public class SqlServerDataLengthFunctionTranslator : IMethodCallTranslator
};
private static readonly HashSet _methodInfoDataLengthMapping
- = new HashSet
+ = new()
{
typeof(SqlServerDbFunctionsExtensions).GetRequiredRuntimeMethod(
nameof(SqlServerDbFunctionsExtensions.DataLength),
diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerDateDiffFunctionsTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerDateDiffFunctionsTranslator.cs
index e5f442c4c57..e85c152236a 100644
--- a/src/EFCore.SqlServer/Query/Internal/SqlServerDateDiffFunctionsTranslator.cs
+++ b/src/EFCore.SqlServer/Query/Internal/SqlServerDateDiffFunctionsTranslator.cs
@@ -23,7 +23,7 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal
public class SqlServerDateDiffFunctionsTranslator : IMethodCallTranslator
{
private readonly Dictionary _methodInfoDateDiffMapping
- = new Dictionary
+ = new()
{
{
typeof(SqlServerDbFunctionsExtensions).GetRequiredRuntimeMethod(
diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMemberTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMemberTranslator.cs
index 79e82ade0d6..f7af119b09c 100644
--- a/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMemberTranslator.cs
+++ b/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMemberTranslator.cs
@@ -24,7 +24,7 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal
public class SqlServerDateTimeMemberTranslator : IMemberTranslator
{
private static readonly Dictionary _datePartMapping
- = new Dictionary
+ = new()
{
{ nameof(DateTime.Year), "year" },
{ nameof(DateTime.Month), "month" },
diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMethodTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMethodTranslator.cs
index 0f862f5d450..131d61107b2 100644
--- a/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMethodTranslator.cs
+++ b/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMethodTranslator.cs
@@ -23,7 +23,7 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal
///
public class SqlServerDateTimeMethodTranslator : IMethodCallTranslator
{
- private readonly Dictionary _methodInfoDatePartMapping = new Dictionary
+ private readonly Dictionary _methodInfoDatePartMapping = new()
{
{ typeof(DateTime).GetRequiredRuntimeMethod(nameof(DateTime.AddYears), new[] { typeof(int) }), "year" },
{ typeof(DateTime).GetRequiredRuntimeMethod(nameof(DateTime.AddMonths), new[] { typeof(int) }), "month" },
diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs
index a7a9fddec66..2a8f25d5099 100644
--- a/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs
+++ b/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs
@@ -23,7 +23,7 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal
///
public class SqlServerMathTranslator : IMethodCallTranslator
{
- private static readonly Dictionary _supportedMethodTranslations = new Dictionary
+ private static readonly Dictionary _supportedMethodTranslations = new()
{
{ typeof(Math).GetRequiredRuntimeMethod(nameof(Math.Abs), new[] { typeof(decimal) }), "ABS" },
{ typeof(Math).GetRequiredRuntimeMethod(nameof(Math.Abs), new[] { typeof(double) }), "ABS" },
diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs
index 60035b4be6b..0c8efe74043 100644
--- a/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs
+++ b/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs
@@ -25,7 +25,7 @@ public class SqlServerObjectToStringTranslator : IMethodCallTranslator
private const int DefaultLength = 100;
private static readonly Dictionary _typeMapping
- = new Dictionary
+ = new()
{
{ typeof(sbyte), "varchar(4)" },
{ typeof(byte), "varchar(3)" },
diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs
index f84250b6b63..da223af03e1 100644
--- a/src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs
+++ b/src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs
@@ -21,7 +21,7 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal
public class SqlServerSqlTranslatingExpressionVisitor : RelationalSqlTranslatingExpressionVisitor
{
private static readonly HashSet _dateTimeDataTypes
- = new HashSet
+ = new()
{
"time",
"date",
@@ -31,7 +31,7 @@ private static readonly HashSet _dateTimeDataTypes
};
private static readonly HashSet _arithmeticOperatorTypes
- = new HashSet
+ = new()
{
ExpressionType.Add,
ExpressionType.Subtract,
diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerTimeSpanMemberTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerTimeSpanMemberTranslator.cs
index 26077a407b6..3057d2f09b5 100644
--- a/src/EFCore.SqlServer/Query/Internal/SqlServerTimeSpanMemberTranslator.cs
+++ b/src/EFCore.SqlServer/Query/Internal/SqlServerTimeSpanMemberTranslator.cs
@@ -22,7 +22,7 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal
///
public class SqlServerTimeSpanMemberTranslator : IMemberTranslator
{
- private static readonly Dictionary _datePartMappings = new Dictionary
+ private static readonly Dictionary _datePartMappings = new()
{
{ nameof(TimeSpan.Hours), "hour" },
{ nameof(TimeSpan.Minutes), "minute" },
diff --git a/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerCodeGenerator.cs b/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerCodeGenerator.cs
index da6e9d7e4cb..1b3ce7615e7 100644
--- a/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerCodeGenerator.cs
+++ b/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerCodeGenerator.cs
@@ -35,7 +35,7 @@ public SqlServerCodeGenerator([NotNull] ProviderCodeGeneratorDependencies depend
public override MethodCallCodeFragment GenerateUseProvider(
string connectionString,
MethodCallCodeFragment? providerOptions)
- => new MethodCallCodeFragment(
+ => new(
nameof(SqlServerDbContextOptionsExtensions.UseSqlServer),
providerOptions == null
? new object[] { connectionString }
diff --git a/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerDatabaseModelFactory.cs b/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerDatabaseModelFactory.cs
index 2d356657808..4bcd923c989 100644
--- a/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerDatabaseModelFactory.cs
+++ b/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerDatabaseModelFactory.cs
@@ -57,7 +57,7 @@ private const string _namePartRegex
= @"(?:(?:\[(?(?:(?:\]\])|[^\]])+)\])|(?[^\.\[\]]+))";
private static readonly Regex _partExtractor
- = new Regex(
+ = new(
string.Format(
CultureInfo.InvariantCulture,
@"^{0}(?:\.{1})?$",
@@ -69,7 +69,7 @@ private static readonly Regex _partExtractor
// see https://msdn.microsoft.com/en-us/library/ff878091.aspx
// decimal/numeric are excluded because default value varies based on the precision.
private static readonly Dictionary _defaultSequenceMinMax =
- new Dictionary(StringComparer.OrdinalIgnoreCase)
+ new(StringComparer.OrdinalIgnoreCase)
{
{ "tinyint", new[] { 0L, 255L } },
{ "smallint", new[] { -32768L, 32767L } },
diff --git a/src/EFCore.SqlServer/Storage/Internal/SqlServerTypeMappingSource.cs b/src/EFCore.SqlServer/Storage/Internal/SqlServerTypeMappingSource.cs
index 37c798a9ac5..6e129f0105c 100644
--- a/src/EFCore.SqlServer/Storage/Internal/SqlServerTypeMappingSource.cs
+++ b/src/EFCore.SqlServer/Storage/Internal/SqlServerTypeMappingSource.cs
@@ -57,64 +57,64 @@ private readonly SqlServerByteArrayTypeMapping _rowversion
storeTypePostfix: StoreTypePostfix.None);
private readonly IntTypeMapping _int
- = new IntTypeMapping("int", DbType.Int32);
+ = new("int", DbType.Int32);
private readonly BoolTypeMapping _bool
= new SqlServerBoolTypeMapping("bit");
private readonly SqlServerStringTypeMapping _fixedLengthUnicodeString
- = new SqlServerStringTypeMapping(unicode: true, fixedLength: true);
+ = new(unicode: true, fixedLength: true);
private readonly SqlServerStringTypeMapping _textUnicodeString
- = new SqlServerStringTypeMapping("ntext", unicode: true, sqlDbType: SqlDbType.NText, storeTypePostfix: StoreTypePostfix.None);
+ = new("ntext", unicode: true, sqlDbType: SqlDbType.NText, storeTypePostfix: StoreTypePostfix.None);
private readonly SqlServerStringTypeMapping _variableLengthUnicodeString
- = new SqlServerStringTypeMapping(unicode: true);
+ = new(unicode: true);
private readonly SqlServerStringTypeMapping _variableLengthMaxUnicodeString
- = new SqlServerStringTypeMapping("nvarchar(max)", unicode: true, storeTypePostfix: StoreTypePostfix.None);
+ = new("nvarchar(max)", unicode: true, storeTypePostfix: StoreTypePostfix.None);
private readonly SqlServerStringTypeMapping _fixedLengthAnsiString
- = new SqlServerStringTypeMapping(fixedLength: true);
+ = new(fixedLength: true);
private readonly SqlServerStringTypeMapping _textAnsiString
- = new SqlServerStringTypeMapping("text", sqlDbType: SqlDbType.Text, storeTypePostfix: StoreTypePostfix.None);
+ = new("text", sqlDbType: SqlDbType.Text, storeTypePostfix: StoreTypePostfix.None);
private readonly SqlServerStringTypeMapping _variableLengthAnsiString
- = new SqlServerStringTypeMapping();
+ = new();
private readonly SqlServerStringTypeMapping _variableLengthMaxAnsiString
- = new SqlServerStringTypeMapping("varchar(max)", storeTypePostfix: StoreTypePostfix.None);
+ = new("varchar(max)", storeTypePostfix: StoreTypePostfix.None);
private readonly SqlServerByteArrayTypeMapping _variableLengthBinary
- = new SqlServerByteArrayTypeMapping();
+ = new();
private readonly SqlServerByteArrayTypeMapping _imageBinary
- = new SqlServerByteArrayTypeMapping("image", sqlDbType: SqlDbType.Image);
+ = new("image", sqlDbType: SqlDbType.Image);
private readonly SqlServerByteArrayTypeMapping _variableLengthMaxBinary
- = new SqlServerByteArrayTypeMapping("varbinary(max)", storeTypePostfix: StoreTypePostfix.None);
+ = new("varbinary(max)", storeTypePostfix: StoreTypePostfix.None);
private readonly SqlServerByteArrayTypeMapping _fixedLengthBinary
- = new SqlServerByteArrayTypeMapping(fixedLength: true);
+ = new(fixedLength: true);
private readonly SqlServerDateTimeTypeMapping _date
- = new SqlServerDateTimeTypeMapping("date", DbType.Date);
+ = new("date", DbType.Date);
private readonly SqlServerDateTimeTypeMapping _datetime
- = new SqlServerDateTimeTypeMapping("datetime", DbType.DateTime);
+ = new("datetime", DbType.DateTime);
private readonly SqlServerDateTimeTypeMapping _datetime2
- = new SqlServerDateTimeTypeMapping("datetime2", DbType.DateTime2);
+ = new("datetime2", DbType.DateTime2);
private readonly DoubleTypeMapping _double
= new SqlServerDoubleTypeMapping("float");
private readonly SqlServerDateTimeOffsetTypeMapping _datetimeoffset
- = new SqlServerDateTimeOffsetTypeMapping("datetimeoffset");
+ = new("datetimeoffset");
private readonly GuidTypeMapping _uniqueidentifier
- = new GuidTypeMapping("uniqueidentifier", DbType.Guid);
+ = new("uniqueidentifier", DbType.Guid);
private readonly DecimalTypeMapping _decimal
= new SqlServerDecimalTypeMapping(
@@ -131,7 +131,7 @@ private readonly TimeSpanTypeMapping _time
= new SqlServerTimeSpanTypeMapping("time");
private readonly SqlServerStringTypeMapping _xml
- = new SqlServerStringTypeMapping("xml", unicode: true, storeTypePostfix: StoreTypePostfix.None);
+ = new("xml", unicode: true, storeTypePostfix: StoreTypePostfix.None);
private readonly Dictionary _clrTypeMappings;
diff --git a/src/EFCore.SqlServer/Update/Internal/SqlServerModificationCommandBatch.cs b/src/EFCore.SqlServer/Update/Internal/SqlServerModificationCommandBatch.cs
index d81f76e1b21..f6e2648e38c 100644
--- a/src/EFCore.SqlServer/Update/Internal/SqlServerModificationCommandBatch.cs
+++ b/src/EFCore.SqlServer/Update/Internal/SqlServerModificationCommandBatch.cs
@@ -25,7 +25,7 @@ public class SqlServerModificationCommandBatch : AffectedCountModificationComman
private const int MaxRowCount = 1000;
private int _parameterCount = 1; // Implicit parameter for the command text
private readonly int _maxBatchSize;
- private readonly List _bulkInsertCommands = new List();
+ private readonly List _bulkInsertCommands = new();
private int _commandsLeftToLengthCheck = 50;
///
diff --git a/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerValueGeneratorCache.cs b/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerValueGeneratorCache.cs
index fec6a2fa60f..342b429b327 100644
--- a/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerValueGeneratorCache.cs
+++ b/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerValueGeneratorCache.cs
@@ -27,7 +27,7 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.ValueGeneration.Internal
public class SqlServerValueGeneratorCache : ValueGeneratorCache, ISqlServerValueGeneratorCache
{
private readonly ConcurrentDictionary _sequenceGeneratorCache
- = new ConcurrentDictionary();
+ = new();
///
/// Initializes a new instance of the class.
diff --git a/src/EFCore.Sqlite.Core/Diagnostics/SqliteEventId.cs b/src/EFCore.Sqlite.Core/Diagnostics/SqliteEventId.cs
index a7fb794c4af..fe81b17198e 100644
--- a/src/EFCore.Sqlite.Core/Diagnostics/SqliteEventId.cs
+++ b/src/EFCore.Sqlite.Core/Diagnostics/SqliteEventId.cs
@@ -50,7 +50,7 @@ private enum Id
private static readonly string _validationPrefix = DbLoggerCategory.Model.Validation.Name + ".";
private static EventId MakeValidationId(Id id)
- => new EventId((int)id, _validationPrefix + id);
+ => new((int)id, _validationPrefix + id);
///
///
@@ -81,7 +81,7 @@ private static EventId MakeValidationId(Id id)
private static readonly string _infraPrefix = DbLoggerCategory.Infrastructure.Name + ".";
private static EventId MakeInfraId(Id id)
- => new EventId((int)id, _infraPrefix + id);
+ => new((int)id, _infraPrefix + id);
///
///
@@ -100,7 +100,7 @@ private static EventId MakeInfraId(Id id)
private static readonly string _migrationsPrefix = DbLoggerCategory.Migrations.Name + ".";
private static EventId MakeMigrationsId(Id id)
- => new EventId((int)id, _migrationsPrefix + id);
+ => new((int)id, _migrationsPrefix + id);
///
/// An operation may fail due to a pending rebuild of the table.
@@ -111,7 +111,7 @@ private static EventId MakeMigrationsId(Id id)
private static readonly string _scaffoldingPrefix = DbLoggerCategory.Scaffolding.Name + ".";
private static EventId MakeScaffoldingId(Id id)
- => new EventId((int)id, _scaffoldingPrefix + id);
+ => new((int)id, _scaffoldingPrefix + id);
///
/// A column was found.
diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteCharMethodTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteCharMethodTranslator.cs
index 8adc6608897..3d190c6443f 100644
--- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteCharMethodTranslator.cs
+++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteCharMethodTranslator.cs
@@ -23,7 +23,7 @@ namespace Microsoft.EntityFrameworkCore.Sqlite.Query.Internal
///
public class SqliteCharMethodTranslator : IMethodCallTranslator
{
- private static readonly Dictionary _supportedMethods = new Dictionary
+ private static readonly Dictionary _supportedMethods = new()
{
{ typeof(char).GetRequiredRuntimeMethod(nameof(char.ToLower), new[] { typeof(char) }), "lower" },
{ typeof(char).GetRequiredRuntimeMethod(nameof(char.ToUpper), new[] { typeof(char) }), "upper" }
diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeAddTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeAddTranslator.cs
index 8c473d5c381..256e32b381a 100644
--- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeAddTranslator.cs
+++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeAddTranslator.cs
@@ -28,7 +28,7 @@ private static readonly MethodInfo _addMilliseconds
private static readonly MethodInfo _addTicks
= typeof(DateTime).GetRequiredRuntimeMethod(nameof(DateTime.AddTicks), new[] { typeof(long) });
- private readonly Dictionary _methodInfoToUnitSuffix = new Dictionary
+ private readonly Dictionary _methodInfoToUnitSuffix = new()
{
{ typeof(DateTime).GetRequiredRuntimeMethod(nameof(DateTime.AddYears), new[] { typeof(int) }), " years" },
{ typeof(DateTime).GetRequiredRuntimeMethod(nameof(DateTime.AddMonths), new[] { typeof(int) }), " months" },
diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeMemberTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeMemberTranslator.cs
index 1e058dac7ee..c81ef13f840 100644
--- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeMemberTranslator.cs
+++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeMemberTranslator.cs
@@ -23,7 +23,7 @@ namespace Microsoft.EntityFrameworkCore.Sqlite.Query.Internal
public class SqliteDateTimeMemberTranslator : IMemberTranslator
{
private static readonly Dictionary _datePartMapping
- = new Dictionary
+ = new()
{
{ nameof(DateTime.Year), "%Y" },
{ nameof(DateTime.Month), "%m" },
diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs
index 93fe90b8efc..3c17d812412 100644
--- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs
+++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs
@@ -24,7 +24,7 @@ namespace Microsoft.EntityFrameworkCore.Sqlite.Query.Internal
///
public class SqliteMathTranslator : IMethodCallTranslator
{
- private static readonly Dictionary _supportedMethods = new Dictionary
+ private static readonly Dictionary _supportedMethods = new()
{
{ typeof(Math).GetRequiredMethod(nameof(Math.Abs), new[] { typeof(double) }), "abs" },
{ typeof(Math).GetRequiredMethod(nameof(Math.Abs), new[] { typeof(float) }), "abs" },
diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteObjectToStringTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteObjectToStringTranslator.cs
index 39c202b43dd..d0f5ccab6df 100644
--- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteObjectToStringTranslator.cs
+++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteObjectToStringTranslator.cs
@@ -22,8 +22,8 @@ namespace Microsoft.EntityFrameworkCore.Sqlite.Query.Internal
///
public class SqliteObjectToStringTranslator : IMethodCallTranslator
{
- private static readonly HashSet _typeMapping = new HashSet
- {
+ private static readonly HashSet _typeMapping = new()
+ {
typeof(bool),
typeof(byte),
typeof(byte[]),
diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteQueryTranslationPostprocessor.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteQueryTranslationPostprocessor.cs
index f604da8e350..51bc6994add 100644
--- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteQueryTranslationPostprocessor.cs
+++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteQueryTranslationPostprocessor.cs
@@ -21,7 +21,7 @@ namespace Microsoft.EntityFrameworkCore.Sqlite.Query.Internal
///
public class SqliteQueryTranslationPostprocessor : RelationalQueryTranslationPostprocessor
{
- private readonly ApplyValidatingVisitor _applyValidator = new ApplyValidatingVisitor();
+ private readonly ApplyValidatingVisitor _applyValidator = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Sqlite.Core/Scaffolding/Internal/SqliteCodeGenerator.cs b/src/EFCore.Sqlite.Core/Scaffolding/Internal/SqliteCodeGenerator.cs
index 58ac03204c0..4cdd63a7740 100644
--- a/src/EFCore.Sqlite.Core/Scaffolding/Internal/SqliteCodeGenerator.cs
+++ b/src/EFCore.Sqlite.Core/Scaffolding/Internal/SqliteCodeGenerator.cs
@@ -33,7 +33,7 @@ public SqliteCodeGenerator([NotNull] ProviderCodeGeneratorDependencies dependenc
public override MethodCallCodeFragment GenerateUseProvider(
string connectionString,
MethodCallCodeFragment providerOptions)
- => new MethodCallCodeFragment(
+ => new(
nameof(SqliteDbContextOptionsBuilderExtensions.UseSqlite),
providerOptions == null
? new object[] { connectionString }
diff --git a/src/EFCore.Sqlite.Core/Storage/Internal/SqliteTypeMappingSource.cs b/src/EFCore.Sqlite.Core/Storage/Internal/SqliteTypeMappingSource.cs
index be0b577c5c9..c982ea778e9 100644
--- a/src/EFCore.Sqlite.Core/Storage/Internal/SqliteTypeMappingSource.cs
+++ b/src/EFCore.Sqlite.Core/Storage/Internal/SqliteTypeMappingSource.cs
@@ -28,7 +28,7 @@ namespace Microsoft.EntityFrameworkCore.Sqlite.Storage.Internal
public class SqliteTypeMappingSource : RelationalTypeMappingSource
{
private static readonly HashSet _spatialiteTypes
- = new HashSet(StringComparer.OrdinalIgnoreCase)
+ = new(StringComparer.OrdinalIgnoreCase)
{
"GEOMETRY",
"GEOMETRYZ",
diff --git a/src/EFCore.Sqlite.NTS/Scaffolding/Internal/SqliteNetTopologySuiteCodeGeneratorPlugin.cs b/src/EFCore.Sqlite.NTS/Scaffolding/Internal/SqliteNetTopologySuiteCodeGeneratorPlugin.cs
index 838771b327d..5560fe3ab21 100644
--- a/src/EFCore.Sqlite.NTS/Scaffolding/Internal/SqliteNetTopologySuiteCodeGeneratorPlugin.cs
+++ b/src/EFCore.Sqlite.NTS/Scaffolding/Internal/SqliteNetTopologySuiteCodeGeneratorPlugin.cs
@@ -21,7 +21,7 @@ public class SqliteNetTopologySuiteCodeGeneratorPlugin : ProviderCodeGeneratorPl
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override MethodCallCodeFragment GenerateProviderOptions()
- => new MethodCallCodeFragment(
+ => new(
nameof(SqliteNetTopologySuiteDbContextOptionsBuilderExtensions.UseNetTopologySuite));
}
}
diff --git a/src/EFCore/ChangeTracking/ChangeTracker.cs b/src/EFCore/ChangeTracking/ChangeTracker.cs
index 37ca85169e8..3ef698aea31 100644
--- a/src/EFCore/ChangeTracking/ChangeTracker.cs
+++ b/src/EFCore/ChangeTracking/ChangeTracker.cs
@@ -441,7 +441,7 @@ public virtual void Clear()
///
///
public virtual DebugView DebugView
- => new DebugView(
+ => new(
() => this.ToDebugString(ChangeTrackerDebugStringOptions.ShortDefault),
() => this.ToDebugString(ChangeTrackerDebugStringOptions.LongDefault));
diff --git a/src/EFCore/ChangeTracking/ChangeTrackerExtensions.cs b/src/EFCore/ChangeTracking/ChangeTrackerExtensions.cs
index 87db70ecb50..2e8e9330d82 100644
--- a/src/EFCore/ChangeTracking/ChangeTrackerExtensions.cs
+++ b/src/EFCore/ChangeTracking/ChangeTrackerExtensions.cs
@@ -51,7 +51,7 @@ public static string ToDebugString(
private sealed class EntityEntryComparer : IComparer
{
- public static readonly EntityEntryComparer Instance = new EntityEntryComparer();
+ public static readonly EntityEntryComparer Instance = new();
public int Compare(InternalEntityEntry x, InternalEntityEntry y)
{
diff --git a/src/EFCore/ChangeTracking/CollectionEntry`.cs b/src/EFCore/ChangeTracking/CollectionEntry`.cs
index 3e3842970c2..380eee2613f 100644
--- a/src/EFCore/ChangeTracking/CollectionEntry`.cs
+++ b/src/EFCore/ChangeTracking/CollectionEntry`.cs
@@ -55,7 +55,7 @@ public CollectionEntry([NotNull] InternalEntityEntry internalEntry, [NotNull] IN
///
/// An entry for the entity that owns this member.
public new virtual EntityEntry EntityEntry
- => new EntityEntry(InternalEntry);
+ => new(InternalEntry);
///
/// Gets or sets the value currently assigned to this property. If the current value is set using this property,
diff --git a/src/EFCore/ChangeTracking/EntityEntry.cs b/src/EFCore/ChangeTracking/EntityEntry.cs
index 0275c9dc225..1f11fc18282 100644
--- a/src/EFCore/ChangeTracking/EntityEntry.cs
+++ b/src/EFCore/ChangeTracking/EntityEntry.cs
@@ -451,7 +451,7 @@ public override string ToString()
///
///
public virtual DebugView DebugView
- => new DebugView(
+ => new(
() => InternalEntry.ToDebugString(ChangeTrackerDebugStringOptions.ShortDefault),
() => InternalEntry.ToDebugString(ChangeTrackerDebugStringOptions.LongDefault));
diff --git a/src/EFCore/ChangeTracking/EntityEntryGraphNode.cs b/src/EFCore/ChangeTracking/EntityEntryGraphNode.cs
index c3a927eb782..d50056a71a6 100644
--- a/src/EFCore/ChangeTracking/EntityEntryGraphNode.cs
+++ b/src/EFCore/ChangeTracking/EntityEntryGraphNode.cs
@@ -75,7 +75,7 @@ public virtual EntityEntry SourceEntry
///
///
public virtual EntityEntry Entry
- => new EntityEntry(_entry);
+ => new(_entry);
///
///
diff --git a/src/EFCore/ChangeTracking/Internal/ChangeTrackerFactory.cs b/src/EFCore/ChangeTracking/Internal/ChangeTrackerFactory.cs
index 52edb14596f..b6bd89481bd 100644
--- a/src/EFCore/ChangeTracking/Internal/ChangeTrackerFactory.cs
+++ b/src/EFCore/ChangeTracking/Internal/ChangeTrackerFactory.cs
@@ -57,6 +57,6 @@ public ChangeTrackerFactory(
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public virtual ChangeTracker Create()
- => new ChangeTracker(_context, _stateManager, _changeDetector, _model, _graphIterator);
+ => new(_context, _stateManager, _changeDetector, _model, _graphIterator);
}
}
diff --git a/src/EFCore/ChangeTracking/Internal/InternalEntityEntry.cs b/src/EFCore/ChangeTracking/Internal/InternalEntityEntry.cs
index 22faa258d8c..e33f16faf63 100644
--- a/src/EFCore/ChangeTracking/Internal/InternalEntityEntry.cs
+++ b/src/EFCore/ChangeTracking/Internal/InternalEntityEntry.cs
@@ -1608,7 +1608,7 @@ public virtual bool IsKeyUnknown
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public virtual EntityEntry ToEntityEntry()
- => new EntityEntry(this);
+ => new(this);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -1738,7 +1738,7 @@ public override string ToString()
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public virtual DebugView DebugView
- => new DebugView(
+ => new(
() => this.ToDebugString(ChangeTrackerDebugStringOptions.ShortDefault),
() => this.ToDebugString(ChangeTrackerDebugStringOptions.LongDefault));
diff --git a/src/EFCore/ChangeTracking/Internal/ValueGenerationManager.cs b/src/EFCore/ChangeTracking/Internal/ValueGenerationManager.cs
index f3caa8e41ad..95603dfb2e9 100644
--- a/src/EFCore/ChangeTracking/Internal/ValueGenerationManager.cs
+++ b/src/EFCore/ChangeTracking/Internal/ValueGenerationManager.cs
@@ -33,10 +33,8 @@ public class ValueGenerationManager : IValueGenerationManager
private readonly IKeyPropagator _keyPropagator;
private readonly IDiagnosticsLogger _logger;
private readonly ILoggingOptions _loggingOptions;
- private readonly Dictionary> _entityTypePropagatingPropertiesMap
- = new Dictionary>();
- private readonly Dictionary> _entityTypeGeneratingPropertiesMap
- = new Dictionary>();
+ private readonly Dictionary> _entityTypePropagatingPropertiesMap = new();
+ private readonly Dictionary> _entityTypeGeneratingPropertiesMap = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore/ChangeTracking/MemberEntry.cs b/src/EFCore/ChangeTracking/MemberEntry.cs
index 4db26bffda0..1dacf22f31b 100644
--- a/src/EFCore/ChangeTracking/MemberEntry.cs
+++ b/src/EFCore/ChangeTracking/MemberEntry.cs
@@ -88,7 +88,7 @@ public virtual object CurrentValue
///
/// An entry for the entity that owns this member.
public virtual EntityEntry EntityEntry
- => new EntityEntry(InternalEntry);
+ => new(InternalEntry);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore/ChangeTracking/ObservableHashSet.cs b/src/EFCore/ChangeTracking/ObservableHashSet.cs
index cec1a54cde2..ca8ca0795fc 100644
--- a/src/EFCore/ChangeTracking/ObservableHashSet.cs
+++ b/src/EFCore/ChangeTracking/ObservableHashSet.cs
@@ -484,11 +484,8 @@ protected virtual void OnCollectionChanged([NotNull] NotifyCollectionChangedEven
internal static class ObservableHashSetSingletons
{
- public static readonly PropertyChangedEventArgs _countPropertyChanged
- = new PropertyChangedEventArgs("Count");
-
- public static readonly PropertyChangingEventArgs _countPropertyChanging
- = new PropertyChangingEventArgs("Count");
+ public static readonly PropertyChangedEventArgs _countPropertyChanged = new("Count");
+ public static readonly PropertyChangingEventArgs _countPropertyChanging = new("Count");
public static readonly object[] _noItems = Array.Empty();
}
diff --git a/src/EFCore/ChangeTracking/PropertyEntry`.cs b/src/EFCore/ChangeTracking/PropertyEntry`.cs
index c9d1823b613..4645a70aaa7 100644
--- a/src/EFCore/ChangeTracking/PropertyEntry`.cs
+++ b/src/EFCore/ChangeTracking/PropertyEntry`.cs
@@ -51,7 +51,7 @@ public PropertyEntry([NotNull] InternalEntityEntry internalEntry, [NotNull] IPro
///
/// An entry for the entity that owns this member.
public new virtual EntityEntry EntityEntry
- => new EntityEntry(InternalEntry);
+ => new(InternalEntry);
///
/// Gets or sets the value currently assigned to this property. If the current value is set using this property,
diff --git a/src/EFCore/ChangeTracking/ReferenceEntry`.cs b/src/EFCore/ChangeTracking/ReferenceEntry`.cs
index a612aba30e8..1fed0cbb501 100644
--- a/src/EFCore/ChangeTracking/ReferenceEntry`.cs
+++ b/src/EFCore/ChangeTracking/ReferenceEntry`.cs
@@ -54,7 +54,7 @@ public ReferenceEntry([NotNull] InternalEntityEntry internalEntry, [NotNull] INa
///
/// An entry for the entity that owns this member.
public new virtual EntityEntry EntityEntry
- => new EntityEntry(InternalEntry);
+ => new(InternalEntry);
///
/// The of the entity this navigation targets.
diff --git a/src/EFCore/DbContext.cs b/src/EFCore/DbContext.cs
index d6c36a28001..5828ad0d1e6 100644
--- a/src/EFCore/DbContext.cs
+++ b/src/EFCore/DbContext.cs
@@ -151,7 +151,7 @@ public virtual IModel Model
///
///
public virtual DbContextId ContextId
- => new DbContextId(_contextId, _leaseCount);
+ => new(_contextId, _leaseCount);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -889,7 +889,7 @@ public virtual EntityEntry Entry([NotNull] TEntity entity)
private EntityEntry EntryWithoutDetectChanges(TEntity entity)
where TEntity : class
- => new EntityEntry(DbContextDependencies.StateManager.GetOrCreateEntry(entity));
+ => new(DbContextDependencies.StateManager.GetOrCreateEntry(entity));
///
///
@@ -917,7 +917,7 @@ public virtual EntityEntry Entry([NotNull] object entity)
}
private EntityEntry EntryWithoutDetectChanges(object entity)
- => new EntityEntry(DbContextDependencies.StateManager.GetOrCreateEntry(entity));
+ => new(DbContextDependencies.StateManager.GetOrCreateEntry(entity));
private void SetEntityState(InternalEntityEntry entry, EntityState entityState)
{
diff --git a/src/EFCore/DbFunctions.cs b/src/EFCore/DbFunctions.cs
index 7eff596ed09..84bb0c8509a 100644
--- a/src/EFCore/DbFunctions.cs
+++ b/src/EFCore/DbFunctions.cs
@@ -17,7 +17,7 @@ private DbFunctions()
{
}
- internal static DbFunctions Instance { get; } = new DbFunctions();
+ internal static DbFunctions Instance { get; } = new();
#region Hidden System.Object members
diff --git a/src/EFCore/Diagnostics/CoreEventId.cs b/src/EFCore/Diagnostics/CoreEventId.cs
index b5c7f3d3058..afc1b71d086 100644
--- a/src/EFCore/Diagnostics/CoreEventId.cs
+++ b/src/EFCore/Diagnostics/CoreEventId.cs
@@ -127,7 +127,7 @@ private enum Id
private static readonly string _updatePrefix = DbLoggerCategory.Update.Name + ".";
private static EventId MakeUpdateId(Id id)
- => new EventId((int)id, _updatePrefix + id);
+ => new((int)id, _updatePrefix + id);
///
///
@@ -152,7 +152,7 @@ private static EventId MakeUpdateId(Id id)
private static readonly string _queryPrefix = DbLoggerCategory.Query.Name + ".";
private static EventId MakeQueryId(Id id)
- => new EventId((int)id, _queryPrefix + id);
+ => new((int)id, _queryPrefix + id);
///
///
@@ -275,7 +275,7 @@ public static readonly EventId FirstWithoutOrderByAndFilterWarning
private static readonly string _infraPrefix = DbLoggerCategory.Infrastructure.Name + ".";
private static EventId MakeInfraId(Id id)
- => new EventId((int)id, _infraPrefix + id);
+ => new((int)id, _infraPrefix + id);
///
///
@@ -410,12 +410,12 @@ private static EventId MakeInfraId(Id id)
private static readonly string _modelPrefix = DbLoggerCategory.Model.Name + ".";
private static EventId MakeModelId(Id id)
- => new EventId((int)id, _modelPrefix + id);
+ => new((int)id, _modelPrefix + id);
private static readonly string _modelValidationPrefix = DbLoggerCategory.Model.Validation.Name + ".";
private static EventId MakeModelValidationId(Id id)
- => new EventId((int)id, _modelValidationPrefix + id);
+ => new((int)id, _modelValidationPrefix + id);
///
///
@@ -767,7 +767,7 @@ public static readonly EventId PossibleIncorrectRequiredNavigationWithQueryFilte
private static readonly string _changeTrackingPrefix = DbLoggerCategory.ChangeTracking.Name + ".";
private static EventId MakeChangeTrackingId(Id id)
- => new EventId((int)id, _changeTrackingPrefix + id);
+ => new((int)id, _changeTrackingPrefix + id);
///
///
diff --git a/src/EFCore/Diagnostics/CoreLoggerExtensions.cs b/src/EFCore/Diagnostics/CoreLoggerExtensions.cs
index 76086442e8e..b34d4bd5053 100644
--- a/src/EFCore/Diagnostics/CoreLoggerExtensions.cs
+++ b/src/EFCore/Diagnostics/CoreLoggerExtensions.cs
@@ -115,7 +115,7 @@ private static DbContextErrorEventData CreateDbContextErrorEventData(
DbContext context,
Exception exception,
EventDefinition definition)
- => new DbContextErrorEventData(definition, SaveChangesFailed, context, exception);
+ => new(definition, SaveChangesFailed, context, exception);
private static string SaveChangesFailed(EventDefinitionBase definition, EventData payload)
{
@@ -197,7 +197,7 @@ private static DbContextErrorEventData CreateDbContextErrorEventData(
DbContext context,
Exception exception,
EventDefinition definition)
- => new DbContextErrorEventData(
+ => new(
definition,
OptimisticConcurrencyException,
context,
@@ -3164,7 +3164,7 @@ public static ValueTask> SaveChangesStartingAsync(
}
private static DbContextEventData CreateSaveChangesStartingEventData(DbContext context, EventDefinition definition)
- => new DbContextEventData(
+ => new(
definition,
SaveChangesStarting,
context);
@@ -3255,7 +3255,7 @@ private static SaveChangesCompletedEventData CreateSaveChangesCompletedEventData
DbContext context,
int entitiesSavedCount,
EventDefinition definition)
- => new SaveChangesCompletedEventData(
+ => new(
definition,
SaveChangesCompleted,
context,
diff --git a/src/EFCore/Diagnostics/InterceptionResult.cs b/src/EFCore/Diagnostics/InterceptionResult.cs
index 754ede0b283..4203c535cef 100644
--- a/src/EFCore/Diagnostics/InterceptionResult.cs
+++ b/src/EFCore/Diagnostics/InterceptionResult.cs
@@ -23,7 +23,7 @@ public readonly struct InterceptionResult
/// execution should be suppressed.
///
public static InterceptionResult Suppress()
- => new InterceptionResult(true);
+ => new(true);
private InterceptionResult(bool suppress)
=> IsSuppressed = suppress;
diff --git a/src/EFCore/Diagnostics/InterceptionResult`.cs b/src/EFCore/Diagnostics/InterceptionResult`.cs
index cf6e6d0fe19..15b9d9bc3dd 100644
--- a/src/EFCore/Diagnostics/InterceptionResult`.cs
+++ b/src/EFCore/Diagnostics/InterceptionResult`.cs
@@ -31,7 +31,7 @@ public readonly struct InterceptionResult
///
/// The result to use.
public static InterceptionResult SuppressWithResult([CanBeNull] TResult result)
- => new InterceptionResult(result);
+ => new(result);
private InterceptionResult(TResult result)
{
diff --git a/src/EFCore/Diagnostics/SaveChangesInterceptor.cs b/src/EFCore/Diagnostics/SaveChangesInterceptor.cs
index 08db3f0d38c..993c9212e9c 100644
--- a/src/EFCore/Diagnostics/SaveChangesInterceptor.cs
+++ b/src/EFCore/Diagnostics/SaveChangesInterceptor.cs
@@ -89,7 +89,7 @@ public virtual ValueTask> SavingChangesAsync(
DbContextEventData eventData,
InterceptionResult result,
CancellationToken cancellationToken = default)
- => new ValueTask>(result);
+ => new(result);
///
///
@@ -117,7 +117,7 @@ public virtual ValueTask SavedChangesAsync(
SaveChangesCompletedEventData eventData,
int result,
CancellationToken cancellationToken = default)
- => new ValueTask(result);
+ => new(result);
///
/// Called when an exception has been thrown in .
diff --git a/src/EFCore/Diagnostics/WarningsConfiguration.cs b/src/EFCore/Diagnostics/WarningsConfiguration.cs
index de03142e0bc..0d2106faffd 100644
--- a/src/EFCore/Diagnostics/WarningsConfiguration.cs
+++ b/src/EFCore/Diagnostics/WarningsConfiguration.cs
@@ -22,8 +22,7 @@ namespace Microsoft.EntityFrameworkCore.Diagnostics
///
public class WarningsConfiguration
{
- private Dictionary _explicitBehaviors
- = new Dictionary();
+ private Dictionary _explicitBehaviors = new();
private WarningBehavior _defaultBehavior = WarningBehavior.Log;
@@ -51,7 +50,7 @@ protected WarningsConfiguration([NotNull] WarningsConfiguration copyFrom)
///
/// A clone of this instance, which can be modified before being returned as immutable.
protected virtual WarningsConfiguration Clone()
- => new WarningsConfiguration(this);
+ => new(this);
///
/// The option set from the method.
diff --git a/src/EFCore/Infrastructure/Annotatable.cs b/src/EFCore/Infrastructure/Annotatable.cs
index 8676405f79e..30f35997eb3 100644
--- a/src/EFCore/Infrastructure/Annotatable.cs
+++ b/src/EFCore/Infrastructure/Annotatable.cs
@@ -198,7 +198,7 @@ public virtual object? this[string name]
/// The value to be stored in the annotation.
/// The newly created annotation.
protected virtual Annotation CreateAnnotation([NotNull] string name, [CanBeNull] object? value)
- => new Annotation(name, value);
+ => new(name, value);
///
[DebuggerStepThrough]
diff --git a/src/EFCore/Infrastructure/ConventionAnnotatable.cs b/src/EFCore/Infrastructure/ConventionAnnotatable.cs
index e740f286b16..84f89dcb8fe 100644
--- a/src/EFCore/Infrastructure/ConventionAnnotatable.cs
+++ b/src/EFCore/Infrastructure/ConventionAnnotatable.cs
@@ -121,7 +121,7 @@ private static ConventionAnnotation CreateAnnotation(
string name,
object? value,
ConfigurationSource configurationSource)
- => new ConventionAnnotation(name, value, configurationSource);
+ => new(name, value, configurationSource);
///
IConventionAnnotatableBuilder IConventionAnnotatable.Builder
diff --git a/src/EFCore/Infrastructure/CoreOptionsExtension.cs b/src/EFCore/Infrastructure/CoreOptionsExtension.cs
index d6ec52cfff5..009cde137fd 100644
--- a/src/EFCore/Infrastructure/CoreOptionsExtension.cs
+++ b/src/EFCore/Infrastructure/CoreOptionsExtension.cs
@@ -94,7 +94,7 @@ public virtual DbContextOptionsExtensionInfo Info
///
/// A clone of this instance, which can be modified before being returned as immutable.
protected virtual CoreOptionsExtension Clone()
- => new CoreOptionsExtension(this);
+ => new(this);
///
/// Creates a new instance with all options the same as for this instance, but with the given option changed.
diff --git a/src/EFCore/Infrastructure/EntityFrameworkEventSource.cs b/src/EFCore/Infrastructure/EntityFrameworkEventSource.cs
index 5543cb5af1c..c4cd7d0246e 100644
--- a/src/EFCore/Infrastructure/EntityFrameworkEventSource.cs
+++ b/src/EFCore/Infrastructure/EntityFrameworkEventSource.cs
@@ -35,7 +35,7 @@ public sealed class EntityFrameworkEventSource : EventSource
///
/// The singleton instance of .
///
- public static readonly EntityFrameworkEventSource Log = new EntityFrameworkEventSource();
+ public static readonly EntityFrameworkEventSource Log = new();
private EntityFrameworkEventSource()
: base("Microsoft.EntityFrameworkCore")
diff --git a/src/EFCore/Infrastructure/IndentedStringBuilder.cs b/src/EFCore/Infrastructure/IndentedStringBuilder.cs
index 133793a0718..da13006f769 100644
--- a/src/EFCore/Infrastructure/IndentedStringBuilder.cs
+++ b/src/EFCore/Infrastructure/IndentedStringBuilder.cs
@@ -25,7 +25,7 @@ public class IndentedStringBuilder
private byte _indent;
private bool _indentPending = true;
- private readonly StringBuilder _stringBuilder = new StringBuilder();
+ private readonly StringBuilder _stringBuilder = new();
///
/// The current length of the built string.
diff --git a/src/EFCore/Infrastructure/Internal/ConcurrencyDetector.cs b/src/EFCore/Infrastructure/Internal/ConcurrencyDetector.cs
index 4df03cb21f4..bfd3a149a97 100644
--- a/src/EFCore/Infrastructure/Internal/ConcurrencyDetector.cs
+++ b/src/EFCore/Infrastructure/Internal/ConcurrencyDetector.cs
@@ -27,7 +27,7 @@ namespace Microsoft.EntityFrameworkCore.Infrastructure.Internal
public class ConcurrencyDetector : IConcurrencyDetector
{
private int _inCriticalSection;
- private static readonly AsyncLocal _threadHasLock = new AsyncLocal();
+ private static readonly AsyncLocal _threadHasLock = new();
private int _refCount;
///
diff --git a/src/EFCore/Infrastructure/Internal/DbSetFinder.cs b/src/EFCore/Infrastructure/Internal/DbSetFinder.cs
index 52d1242ff50..58e9062ec98 100644
--- a/src/EFCore/Infrastructure/Internal/DbSetFinder.cs
+++ b/src/EFCore/Infrastructure/Internal/DbSetFinder.cs
@@ -26,8 +26,7 @@ namespace Microsoft.EntityFrameworkCore.Infrastructure.Internal
///
public class DbSetFinder : IDbSetFinder
{
- private readonly ConcurrentDictionary> _cache
- = new ConcurrentDictionary>();
+ private readonly ConcurrentDictionary> _cache = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore/Infrastructure/ModelSource.cs b/src/EFCore/Infrastructure/ModelSource.cs
index ea74e3caea6..25aaf9199af 100644
--- a/src/EFCore/Infrastructure/ModelSource.cs
+++ b/src/EFCore/Infrastructure/ModelSource.cs
@@ -29,7 +29,7 @@ namespace Microsoft.EntityFrameworkCore.Infrastructure
///
public class ModelSource : IModelSource
{
- private readonly object _syncObject = new object();
+ private readonly object _syncObject = new();
///
/// Creates a new instance.
diff --git a/src/EFCore/Internal/DbContextLease.cs b/src/EFCore/Internal/DbContextLease.cs
index 060d955bc65..c6682ea1df3 100644
--- a/src/EFCore/Internal/DbContextLease.cs
+++ b/src/EFCore/Internal/DbContextLease.cs
@@ -23,7 +23,7 @@ public struct DbContextLease
/// 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 static DbContextLease InactiveLease { get; } = new DbContextLease();
+ public static DbContextLease InactiveLease { get; } = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore/Internal/DbContextPool.cs b/src/EFCore/Internal/DbContextPool.cs
index 24983a6917d..ab1f1972bee 100644
--- a/src/EFCore/Internal/DbContextPool.cs
+++ b/src/EFCore/Internal/DbContextPool.cs
@@ -26,7 +26,7 @@ public class DbContextPool : IDbContextPool, IDisposable, IA
{
private const int DefaultPoolSize = 32;
- private readonly ConcurrentQueue _pool = new ConcurrentQueue();
+ private readonly ConcurrentQueue _pool = new();
private readonly Func _activator;
diff --git a/src/EFCore/Internal/DbSetSource.cs b/src/EFCore/Internal/DbSetSource.cs
index b575c6f4b4c..eee8437bf0f 100644
--- a/src/EFCore/Internal/DbSetSource.cs
+++ b/src/EFCore/Internal/DbSetSource.cs
@@ -27,8 +27,7 @@ public class DbSetSource : IDbSetSource
private static readonly MethodInfo _genericCreateSet
= typeof(DbSetSource).GetTypeInfo().GetDeclaredMethod(nameof(CreateSetFactory));
- private readonly ConcurrentDictionary<(Type Type, string Name), Func> _cache
- = new ConcurrentDictionary<(Type Type, string Name), Func>();
+ private readonly ConcurrentDictionary<(Type Type, string Name), Func> _cache = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore/Internal/EntityFinderSource.cs b/src/EFCore/Internal/EntityFinderSource.cs
index ad3efe58b28..3aa38806bc1 100644
--- a/src/EFCore/Internal/EntityFinderSource.cs
+++ b/src/EFCore/Internal/EntityFinderSource.cs
@@ -30,7 +30,7 @@ private static readonly MethodInfo _genericCreate
= typeof(EntityFinderSource).GetTypeInfo().GetDeclaredMethod(nameof(CreateConstructor));
private readonly ConcurrentDictionary> _cache
- = new ConcurrentDictionary>();
+ = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore/Internal/InternalDbSet.cs b/src/EFCore/Internal/InternalDbSet.cs
index 5b6f31cd356..bd3e03d25ba 100644
--- a/src/EFCore/Internal/InternalDbSet.cs
+++ b/src/EFCore/Internal/InternalDbSet.cs
@@ -134,7 +134,7 @@ private EntityQueryable EntityQueryable
}
private EntityQueryable CreateEntityQueryable()
- => new EntityQueryable(_context.GetDependencies().QueryProvider, EntityType);
+ => new(_context.GetDependencies().QueryProvider, EntityType);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -524,7 +524,7 @@ Task IResettableService.ResetStateAsync(CancellationToken cancellationToken)
}
private EntityEntry EntryWithoutDetectChanges(TEntity entity)
- => new EntityEntry(_context.GetDependencies().StateManager.GetOrCreateEntry(entity, EntityType));
+ => new(_context.GetDependencies().StateManager.GetOrCreateEntry(entity, EntityType));
private void SetEntityStates(IEnumerable entities, EntityState entityState)
{
diff --git a/src/EFCore/Internal/ServiceProviderCache.cs b/src/EFCore/Internal/ServiceProviderCache.cs
index 612d952ffe7..fe5e3557e80 100644
--- a/src/EFCore/Internal/ServiceProviderCache.cs
+++ b/src/EFCore/Internal/ServiceProviderCache.cs
@@ -23,8 +23,7 @@ namespace Microsoft.EntityFrameworkCore.Internal
public class ServiceProviderCache
{
private readonly ConcurrentDictionary DebugInfo)>
- _configurations
- = new ConcurrentDictionary)>();
+ _configurations = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -32,7 +31,7 @@ public class ServiceProviderCache
/// 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 static ServiceProviderCache Instance { get; } = new ServiceProviderCache();
+ public static ServiceProviderCache Instance { get; } = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore/Internal/SingletonOptionsInitializer.cs b/src/EFCore/Internal/SingletonOptionsInitializer.cs
index 805054b1345..b8f578d87ff 100644
--- a/src/EFCore/Internal/SingletonOptionsInitializer.cs
+++ b/src/EFCore/Internal/SingletonOptionsInitializer.cs
@@ -24,7 +24,7 @@ namespace Microsoft.EntityFrameworkCore.Internal
public class SingletonOptionsInitializer : ISingletonOptionsInitializer
{
private volatile bool _isInitialized;
- private readonly object _lock = new object();
+ private readonly object _lock = new();
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore/Metadata/Builders/CollectionNavigationBuilder.cs b/src/EFCore/Metadata/Builders/CollectionNavigationBuilder.cs
index 780a4f05962..382d656c5ce 100644
--- a/src/EFCore/Metadata/Builders/CollectionNavigationBuilder.cs
+++ b/src/EFCore/Metadata/Builders/CollectionNavigationBuilder.cs
@@ -121,7 +121,7 @@ IConventionForeignKeyBuilder IInfrastructure.Insta
///
/// An object to further configure the relationship.
public virtual ReferenceCollectionBuilder WithOne([CanBeNull] string navigationName = null)
- => new ReferenceCollectionBuilder(
+ => new(
DeclaringEntityType,
RelatedEntityType,
WithOneBuilder(
diff --git a/src/EFCore/Metadata/Builders/CollectionNavigationBuilder`.cs b/src/EFCore/Metadata/Builders/CollectionNavigationBuilder`.cs
index f3134e5ef46..53d8a370c3a 100644
--- a/src/EFCore/Metadata/Builders/CollectionNavigationBuilder`.cs
+++ b/src/EFCore/Metadata/Builders/CollectionNavigationBuilder`.cs
@@ -55,7 +55,7 @@ public CollectionNavigationBuilder(
public new virtual ReferenceCollectionBuilder WithOne(
[CanBeNull] string navigationName = null)
{
- return new ReferenceCollectionBuilder(
+ return new(
DeclaringEntityType,
RelatedEntityType,
WithOneBuilder(
@@ -80,7 +80,7 @@ public CollectionNavigationBuilder(
/// An object to further configure the relationship.
public virtual ReferenceCollectionBuilder WithOne(
[CanBeNull] Expression> navigationExpression)
- => new ReferenceCollectionBuilder(
+ => new(
DeclaringEntityType,
RelatedEntityType,
WithOneBuilder(navigationExpression?.GetMemberAccess()).Metadata);
diff --git a/src/EFCore/Metadata/Builders/EntityTypeBuilder.cs b/src/EFCore/Metadata/Builders/EntityTypeBuilder.cs
index 3bafd6b7e57..774f84a1a2f 100644
--- a/src/EFCore/Metadata/Builders/EntityTypeBuilder.cs
+++ b/src/EFCore/Metadata/Builders/EntityTypeBuilder.cs
@@ -76,7 +76,7 @@ public virtual EntityTypeBuilder HasAnnotation([NotNull] string annotation, [Not
/// The name of the base type or to indicate no base type.
/// The same builder instance so that multiple configuration calls can be chained.
public virtual EntityTypeBuilder HasBaseType([CanBeNull] string name)
- => new EntityTypeBuilder(Builder.HasBaseType(name, ConfigurationSource.Explicit).Metadata);
+ => new(Builder.HasBaseType(name, ConfigurationSource.Explicit).Metadata);
///
/// Sets the base type of this entity type in an inheritance hierarchy.
@@ -84,7 +84,7 @@ public virtual EntityTypeBuilder HasBaseType([CanBeNull] string name)
/// The base type or to indicate no base type.
/// The same builder instance so that multiple configuration calls can be chained.
public virtual EntityTypeBuilder HasBaseType([CanBeNull] Type entityType)
- => new EntityTypeBuilder(Builder.HasBaseType(entityType, ConfigurationSource.Explicit).Metadata);
+ => new(Builder.HasBaseType(entityType, ConfigurationSource.Explicit).Metadata);
///
/// Sets the properties that make up the primary key for this entity type.
@@ -92,8 +92,7 @@ public virtual EntityTypeBuilder HasBaseType([CanBeNull] Type entityType)
/// The names of the properties that make up the primary key.
/// An object that can be used to configure the primary key.
public virtual KeyBuilder HasKey([NotNull] params string[] propertyNames)
- => new KeyBuilder(
- Builder.PrimaryKey(Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata);
+ => new(Builder.PrimaryKey(Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata);
///
/// Creates an alternate key in the model for this entity type if one does not already exist over the specified
@@ -103,8 +102,7 @@ public virtual KeyBuilder HasKey([NotNull] params string[] propertyNames)
/// The names of the properties that make up the key.
/// An object that can be used to configure the key.
public virtual KeyBuilder HasAlternateKey([NotNull] params string[] propertyNames)
- => new KeyBuilder(
- Builder.HasKey(Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata);
+ => new(Builder.HasKey(Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata);
///
/// Configures the entity type to have no keys. It will only be usable for queries.
@@ -130,7 +128,7 @@ public virtual EntityTypeBuilder HasNoKey()
/// The name of the property to be configured.
/// An object that can be used to configure the property.
public virtual PropertyBuilder Property([NotNull] string propertyName)
- => new PropertyBuilder(
+ => new(
Builder.Property(
Check.NotEmpty(propertyName, nameof(propertyName)),
ConfigurationSource.Explicit).Metadata);
@@ -152,7 +150,7 @@ public virtual PropertyBuilder Property([NotNull] string propertyName)
/// The name of the property to be configured.
/// An object that can be used to configure the property.
public virtual PropertyBuilder Property([NotNull] string propertyName)
- => new PropertyBuilder(
+ => new(
Builder.Property(
typeof(TProperty),
Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit).Metadata);
@@ -174,7 +172,7 @@ public virtual PropertyBuilder Property([NotNull] string p
/// The name of the property to be configured.
/// An object that can be used to configure the property.
public virtual PropertyBuilder Property([NotNull] Type propertyType, [NotNull] string propertyName)
- => new PropertyBuilder(
+ => new(
Builder.Property(
Check.NotNull(propertyType, nameof(propertyType)),
Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit).Metadata);
@@ -194,7 +192,7 @@ public virtual PropertyBuilder Property([NotNull] Type propertyType, [NotNull] s
/// The name of the property to be configured.
/// An object that can be used to configure the property.
public virtual PropertyBuilder IndexerProperty([NotNull] string propertyName)
- => new PropertyBuilder(
+ => new(
Builder.IndexerProperty(
typeof(TProperty),
Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit).Metadata);
@@ -214,7 +212,7 @@ public virtual PropertyBuilder IndexerProperty([NotNull] s
/// The name of the property to be configured.
/// An object that can be used to configure the property.
public virtual PropertyBuilder IndexerProperty([NotNull] Type propertyType, [NotNull] string propertyName)
- => new PropertyBuilder(
+ => new(
Builder.IndexerProperty(
Check.NotNull(propertyType, nameof(propertyType)),
Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit).Metadata);
@@ -228,9 +226,7 @@ public virtual PropertyBuilder IndexerProperty([NotNull] Type propertyType, [Not
/// The name of the navigation property to be configured.
/// An object that can be used to configure the navigation property.
public virtual NavigationBuilder Navigation([NotNull] string navigationName)
- => new NavigationBuilder(
- Builder.Navigation(
- Check.NotEmpty(navigationName, nameof(navigationName))));
+ => new(Builder.Navigation(Check.NotEmpty(navigationName, nameof(navigationName))));
///
/// Excludes the given property from the entity type. This method is typically used to remove properties
@@ -268,8 +264,7 @@ public virtual EntityTypeBuilder HasQueryFilter([CanBeNull] LambdaExpression fil
/// The names of the properties that make up the index.
/// An object that can be used to configure the index.
public virtual IndexBuilder HasIndex([NotNull] params string[] propertyNames)
- => new IndexBuilder(
- Builder.HasIndex(Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata);
+ => new(Builder.HasIndex(Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata);
///
/// Configures an index on the specified properties and with the given name.
@@ -282,7 +277,7 @@ public virtual IndexBuilder HasIndex([NotNull] params string[] propertyNames)
public virtual IndexBuilder HasIndex(
[NotNull] string[] propertyNames,
[NotNull] string name)
- => new IndexBuilder(
+ => new(
Builder.HasIndex(
Check.NotEmpty(propertyNames, nameof(propertyNames)),
Check.NotEmpty(name, nameof(name)),
diff --git a/src/EFCore/Metadata/Builders/EntityTypeBuilder`.cs b/src/EFCore/Metadata/Builders/EntityTypeBuilder`.cs
index c3724d5fe48..26d86824ab2 100644
--- a/src/EFCore/Metadata/Builders/EntityTypeBuilder`.cs
+++ b/src/EFCore/Metadata/Builders/EntityTypeBuilder`.cs
@@ -54,7 +54,7 @@ public EntityTypeBuilder([NotNull] IMutableEntityType entityType)
/// The name of the base type or to indicate no base type.
/// The same builder instance so that multiple configuration calls can be chained.
public new virtual EntityTypeBuilder HasBaseType([CanBeNull] string name)
- => new EntityTypeBuilder(Builder.HasBaseType(name, ConfigurationSource.Explicit).Metadata);
+ => new(Builder.HasBaseType(name, ConfigurationSource.Explicit).Metadata);
///
/// Sets the base type of this entity type in an inheritance hierarchy.
@@ -62,7 +62,7 @@ public EntityTypeBuilder([NotNull] IMutableEntityType entityType)
/// The base type or to indicate no base type.
/// The same builder instance so that multiple configuration calls can be chained.
public new virtual EntityTypeBuilder HasBaseType([CanBeNull] Type entityType)
- => new EntityTypeBuilder(Builder.HasBaseType(entityType, ConfigurationSource.Explicit).Metadata);
+ => new(Builder.HasBaseType(entityType, ConfigurationSource.Explicit).Metadata);
///
/// Sets the base type of this entity type in an inheritance hierarchy.
@@ -97,7 +97,7 @@ public virtual KeyBuilder HasKey([NotNull] Expression> key
/// The names of the properties that make up the primary key.
/// An object that can be used to configure the primary key.
public new virtual KeyBuilder HasKey([NotNull] params string[] propertyNames)
- => new KeyBuilder(
+ => new(
Builder.PrimaryKey(
Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata);
@@ -118,7 +118,7 @@ public virtual KeyBuilder HasKey([NotNull] Expression> key
///
/// An object that can be used to configure the key.
public virtual KeyBuilder HasAlternateKey([NotNull] Expression> keyExpression)
- => new KeyBuilder(
+ => new(
Builder.HasKey(
Check.NotNull(keyExpression, nameof(keyExpression)).GetMemberAccessList(),
ConfigurationSource.Explicit).Metadata);
@@ -132,7 +132,7 @@ public virtual KeyBuilder HasAlternateKey([NotNull] Expression The names of the properties that make up the key.
/// An object that can be used to configure the key.
public new virtual KeyBuilder HasAlternateKey([NotNull] params string[] propertyNames)
- => new KeyBuilder(
+ => new(
Builder.HasKey(
Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata);
@@ -153,7 +153,7 @@ public virtual KeyBuilder HasAlternateKey([NotNull] Expression
/// An object that can be used to configure the property.
public virtual PropertyBuilder Property([NotNull] Expression> propertyExpression)
- => new PropertyBuilder(
+ => new(
Builder.Property(
Check.NotNull(propertyExpression, nameof(propertyExpression)).GetMemberAccess(), ConfigurationSource.Explicit)
.Metadata);
@@ -171,7 +171,7 @@ public virtual PropertyBuilder Property([NotNull] Expressi
public virtual NavigationBuilder Navigation(
[NotNull] Expression> navigationExpression)
where TNavigation : class
- => new NavigationBuilder(
+ => new(
Builder.Navigation(
Check.NotNull(navigationExpression, nameof(navigationExpression)).GetMemberAccess()));
@@ -188,7 +188,7 @@ public virtual NavigationBuilder Navigation(
public virtual NavigationBuilder Navigation(
[NotNull] Expression>> navigationExpression)
where TNavigation : class
- => new NavigationBuilder(
+ => new(
Builder.Navigation(
Check.NotNull(navigationExpression, nameof(navigationExpression)).GetMemberAccess()));
@@ -262,7 +262,7 @@ public virtual EntityTypeBuilder ToQuery([NotNull] Expression
/// An object that can be used to configure the index.
public virtual IndexBuilder HasIndex([NotNull] Expression> indexExpression)
- => new IndexBuilder(
+ => new(
Builder.HasIndex(
Check.NotNull(indexExpression, nameof(indexExpression)).GetMemberAccessList(),
ConfigurationSource.Explicit).Metadata);
@@ -287,7 +287,7 @@ public virtual IndexBuilder HasIndex([NotNull] Expression HasIndex(
[NotNull] Expression> indexExpression,
[NotNull] string name)
- => new IndexBuilder(
+ => new(
Builder.HasIndex(
Check.NotNull(indexExpression, nameof(indexExpression)).GetMemberAccessList(),
name,
@@ -301,7 +301,7 @@ public virtual IndexBuilder HasIndex(
/// The names of the properties that make up the index.
/// An object that can be used to configure the index.
public new virtual IndexBuilder HasIndex([NotNull] params string[] propertyNames)
- => new IndexBuilder(
+ => new(
Builder.HasIndex(
Check.NotEmpty(propertyNames, nameof(propertyNames)),
ConfigurationSource.Explicit).Metadata);
@@ -317,7 +317,7 @@ public virtual IndexBuilder HasIndex(
public new virtual IndexBuilder HasIndex(
[NotNull] string[] propertyNames,
[NotNull] string name)
- => new IndexBuilder(
+ => new(
Builder.HasIndex(
Check.NotEmpty(propertyNames, nameof(propertyNames)),
name,
diff --git a/src/EFCore/Metadata/Builders/OwnedNavigationBuilder.cs b/src/EFCore/Metadata/Builders/OwnedNavigationBuilder.cs
index edb4a20e0c8..0b3c7d525b0 100644
--- a/src/EFCore/Metadata/Builders/OwnedNavigationBuilder.cs
+++ b/src/EFCore/Metadata/Builders/OwnedNavigationBuilder.cs
@@ -127,7 +127,7 @@ public virtual OwnedNavigationBuilder HasAnnotation([NotNull] string annotation,
/// The names of the properties that make up the primary key.
/// An object that can be used to configure the primary key.
public virtual KeyBuilder HasKey([NotNull] params string[] propertyNames)
- => new KeyBuilder(
+ => new(
DependentEntityType.Builder.PrimaryKey(
Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata);
@@ -191,7 +191,7 @@ public virtual PropertyBuilder Property([NotNull] string p
/// The name of the property to be configured.
/// An object that can be used to configure the property.
public virtual PropertyBuilder Property([NotNull] Type propertyType, [NotNull] string propertyName)
- => new PropertyBuilder(
+ => new(
DependentEntityType.Builder.Property(
Check.NotNull(propertyType, nameof(propertyType)),
Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit).Metadata);
@@ -211,7 +211,7 @@ public virtual PropertyBuilder Property([NotNull] Type propertyType, [NotNull] s
/// The name of the property to be configured.
/// An object that can be used to configure the property.
public virtual PropertyBuilder IndexerProperty([NotNull] string propertyName)
- => new PropertyBuilder(
+ => new(
DependentEntityType.Builder.IndexerProperty(
typeof(TProperty),
Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit).Metadata);
@@ -231,7 +231,7 @@ public virtual PropertyBuilder IndexerProperty([NotNull] s
/// The name of the property to be configured.
/// An object that can be used to configure the property.
public virtual PropertyBuilder IndexerProperty([NotNull] Type propertyType, [NotNull] string propertyName)
- => new PropertyBuilder(
+ => new(
DependentEntityType.Builder.IndexerProperty(
Check.NotNull(propertyType, nameof(propertyType)),
Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit).Metadata);
@@ -246,7 +246,7 @@ public virtual PropertyBuilder IndexerProperty([NotNull] Type propertyType, [Not
/// The name of the navigation property to be configured.
/// An object that can be used to configure the navigation property.
public virtual NavigationBuilder Navigation([NotNull] string navigationName)
- => new NavigationBuilder(
+ => new(
DependentEntityType.Builder.Navigation(
Check.NotEmpty(navigationName, nameof(navigationName))));
@@ -271,7 +271,7 @@ public virtual OwnedNavigationBuilder Ignore([NotNull] string propertyName)
/// The names of the properties that make up the index.
/// An object that can be used to configure the index.
public virtual IndexBuilder HasIndex([NotNull] params string[] propertyNames)
- => new IndexBuilder(
+ => new(
DependentEntityType.Builder.HasIndex(
Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata);
diff --git a/src/EFCore/Metadata/Builders/OwnedNavigationBuilder`.cs b/src/EFCore/Metadata/Builders/OwnedNavigationBuilder`.cs
index 83c5e506655..22d65c4a527 100644
--- a/src/EFCore/Metadata/Builders/OwnedNavigationBuilder`.cs
+++ b/src/EFCore/Metadata/Builders/OwnedNavigationBuilder`.cs
@@ -58,7 +58,7 @@ public OwnedNavigationBuilder([NotNull] IMutableForeignKey ownership)
///
/// An object that can be used to configure the primary key.
public virtual KeyBuilder HasKey([NotNull] Expression> keyExpression)
- => new KeyBuilder(
+ => new(
DependentEntityType.Builder.PrimaryKey(
Check.NotNull(keyExpression, nameof(keyExpression)).GetMemberAccessList(), ConfigurationSource.Explicit).Metadata);
@@ -68,7 +68,7 @@ public virtual KeyBuilder HasKey([NotNull] Expression The names of the properties that make up the primary key.
/// An object that can be used to configure the primary key.
public new virtual KeyBuilder HasKey([NotNull] params string[] propertyNames)
- => new KeyBuilder(
+ => new(
DependentEntityType.Builder.PrimaryKey(
Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata);
@@ -115,7 +115,7 @@ public virtual PropertyBuilder Property(
public virtual NavigationBuilder Navigation(
[NotNull] Expression> navigationExpression)
where TNavigation : class
- => new NavigationBuilder(
+ => new(
DependentEntityType.Builder.Navigation(
Check.NotNull(navigationExpression, nameof(navigationExpression)).GetMemberAccess()));
@@ -135,7 +135,7 @@ public virtual NavigationBuilder Navigation Navigation(
[NotNull] Expression>> navigationExpression)
where TNavigation : class
- => new NavigationBuilder(
+ => new(
DependentEntityType.Builder.Navigation(
Check.NotNull(navigationExpression, nameof(navigationExpression)).GetMemberAccess()));
@@ -178,7 +178,7 @@ public virtual OwnedNavigationBuilder Ignore(
///
/// An object that can be used to configure the index.
public virtual IndexBuilder HasIndex([NotNull] Expression> indexExpression)
- => new IndexBuilder(
+ => new(
DependentEntityType.Builder.HasIndex(
Check.NotNull(indexExpression, nameof(indexExpression)).GetMemberAccessList(), ConfigurationSource.Explicit)
.Metadata);
@@ -190,7 +190,7 @@ public virtual IndexBuilder HasIndex([NotNull] Expression The names of the properties that make up the index.
/// An object that can be used to configure the index.
public new virtual IndexBuilder HasIndex([NotNull] params string[] propertyNames)
- => new IndexBuilder(
+ => new(
DependentEntityType.Builder.HasIndex(
Check.NotEmpty(propertyNames, nameof(propertyNames)), ConfigurationSource.Explicit).Metadata);
@@ -241,7 +241,7 @@ public virtual IndexBuilder HasIndex([NotNull] Expression An object that can be used to configure the relationship.
public virtual OwnershipBuilder WithOwner(
[CanBeNull] Expression> referenceExpression)
- => new OwnershipBuilder(
+ => new(
PrincipalEntityType,
DependentEntityType,
Builder.HasNavigation(
diff --git a/src/EFCore/Metadata/Builders/ReferenceCollectionBuilder.cs b/src/EFCore/Metadata/Builders/ReferenceCollectionBuilder.cs
index d9d14bb96c1..baaaf6e06ce 100644
--- a/src/EFCore/Metadata/Builders/ReferenceCollectionBuilder.cs
+++ b/src/EFCore/Metadata/Builders/ReferenceCollectionBuilder.cs
@@ -95,7 +95,7 @@ public virtual ReferenceCollectionBuilder HasAnnotation([NotNull] string annotat
///
/// The same builder instance so that multiple configuration calls can be chained.
public virtual ReferenceCollectionBuilder HasForeignKey([NotNull] params string[] foreignKeyPropertyNames)
- => new ReferenceCollectionBuilder(
+ => new(
HasForeignKeyBuilder(Check.NotEmpty(foreignKeyPropertyNames, nameof(foreignKeyPropertyNames))),
this,
foreignKeySet: true);
@@ -129,7 +129,7 @@ protected virtual InternalForeignKeyBuilder HasForeignKeyBuilder([NotNull] IRead
/// The name(s) of the referenced key property(s).
/// The same builder instance so that multiple configuration calls can be chained.
public virtual ReferenceCollectionBuilder HasPrincipalKey([NotNull] params string[] keyPropertyNames)
- => new ReferenceCollectionBuilder(
+ => new(
HasPrincipalKeyBuilder(Check.NotEmpty(keyPropertyNames, nameof(keyPropertyNames))),
this,
principalKeySet: true);
@@ -161,7 +161,7 @@ protected virtual InternalForeignKeyBuilder HasPrincipalKeyBuilder([NotNull] IRe
/// A value indicating whether this is a required relationship.
/// The same builder instance so that multiple configuration calls can be chained.
public virtual ReferenceCollectionBuilder IsRequired(bool required = true)
- => new ReferenceCollectionBuilder(
+ => new(
Builder.IsRequired(required, ConfigurationSource.Explicit),
this,
requiredSet: true);
@@ -173,8 +173,6 @@ public virtual ReferenceCollectionBuilder IsRequired(bool required = true)
/// The action to perform.
/// The same builder instance so that multiple configuration calls can be chained.
public virtual ReferenceCollectionBuilder OnDelete(DeleteBehavior deleteBehavior)
- => new ReferenceCollectionBuilder(
- Builder.OnDelete(deleteBehavior, ConfigurationSource.Explicit),
- this);
+ => new(Builder.OnDelete(deleteBehavior, ConfigurationSource.Explicit), this);
}
}
diff --git a/src/EFCore/Metadata/Builders/ReferenceCollectionBuilder`.cs b/src/EFCore/Metadata/Builders/ReferenceCollectionBuilder`.cs
index 262917dbf8c..ffa6c144a84 100644
--- a/src/EFCore/Metadata/Builders/ReferenceCollectionBuilder`.cs
+++ b/src/EFCore/Metadata/Builders/ReferenceCollectionBuilder`.cs
@@ -82,7 +82,7 @@ protected ReferenceCollectionBuilder(
/// The same builder instance so that multiple configuration calls can be chained.
public new virtual ReferenceCollectionBuilder HasForeignKey(
[NotNull] params string[] foreignKeyPropertyNames)
- => new ReferenceCollectionBuilder