Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
463 changes: 200 additions & 263 deletions src/EFCore.Cosmos/Infrastructure/Internal/CosmosModelValidator.cs

Large diffs are not rendered by default.

1,005 changes: 515 additions & 490 deletions src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs

Large diffs are not rendered by default.

389 changes: 195 additions & 194 deletions src/EFCore.SqlServer/Infrastructure/Internal/SqlServerModelValidator.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
using Microsoft.EntityFrameworkCore.Sqlite.Internal;

namespace Microsoft.EntityFrameworkCore.Sqlite.Infrastructure.Internal;
Expand All @@ -11,34 +12,35 @@ namespace Microsoft.EntityFrameworkCore.Sqlite.Infrastructure.Internal;
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public class SqliteModelValidator : RelationalModelValidator
public class SqliteModelValidator(
ModelValidatorDependencies dependencies,
RelationalModelValidatorDependencies relationalDependencies)
: RelationalModelValidator(dependencies, relationalDependencies)
{
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public SqliteModelValidator(
ModelValidatorDependencies dependencies,
RelationalModelValidatorDependencies relationalDependencies)
: base(dependencies, relationalDependencies)
public override void Validate(IModel model, IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)
{
base.Validate(model, logger);
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public override void Validate(IModel model, IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)
/// <inheritdoc />
protected override void ValidateEntityType(
IEntityType entityType,
IConventionModel? conventionModel,
bool requireFullNotifications,
HashSet<IEntityType> validEntityTypes,
Dictionary<IKey, IIdentityMap> identityMaps,
bool sensitiveDataLogged,
IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)
{
base.Validate(model, logger);
base.ValidateEntityType(entityType, conventionModel, requireFullNotifications, validEntityTypes, identityMaps, sensitiveDataLogged, logger);

ValidateNoSchemas(model, logger);
ValidateNoSequences(model, logger);
ValidateNoStoredProcedures(model, logger);
ValidateNoSchema(entityType, logger);
}

/// <summary>
Expand All @@ -47,30 +49,25 @@ public override void Validate(IModel model, IDiagnosticsLogger<DbLoggerCategory.
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
protected virtual void ValidateNoSchemas(
IModel model,
protected virtual void ValidateNoSchema(
IEntityType entityType,
IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)
{
foreach (var entityType in model.GetEntityTypes().Where(e => e.GetSchema() != null))
var schema = entityType.GetSchema();
if (schema != null)
{
logger.SchemaConfiguredWarning(entityType, entityType.GetSchema()!);
logger.SchemaConfiguredWarning(entityType, schema);
}
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
protected virtual void ValidateNoSequences(
IModel model,
/// <inheritdoc />
protected override void ValidateSequence(
ISequence sequence,
IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)
{
foreach (var sequence in model.GetSequences())
{
logger.SequenceConfiguredWarning(sequence);
}
base.ValidateSequence(sequence, logger);

logger.SequenceConfiguredWarning(sequence);
}

/// <summary>
Expand All @@ -79,21 +76,19 @@ protected virtual void ValidateNoSequences(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
protected virtual void ValidateNoStoredProcedures(
IModel model,
protected override void ValidateStoredProcedures(
IEntityType entityType,
IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)
{
foreach (var entityType in model.GetEntityTypes())
if (entityType.GetInsertStoredProcedure() is not null
|| entityType.GetUpdateStoredProcedure() is not null
|| entityType.GetDeleteStoredProcedure() is not null)
{
if (entityType.GetInsertStoredProcedure() is not null
|| entityType.GetUpdateStoredProcedure() is not null
|| entityType.GetDeleteStoredProcedure() is not null)
{
throw new InvalidOperationException(SqliteStrings.StoredProceduresNotSupported(entityType.DisplayName()));
}
throw new InvalidOperationException(SqliteStrings.StoredProceduresNotSupported(entityType.DisplayName()));
}
}


/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down
Loading
Loading