Skip to content

Commit

Permalink
Check declaring object status in IsInModel
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriySvyryd committed Sep 13, 2022
1 parent ea5592f commit 017e22e
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/EFCore.Relational/Metadata/Internal/CheckConstraint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ public virtual InternalCheckConstraintBuilder Builder
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool IsInModel
=> _builder is not null;
=> _builder is not null
&& ((IConventionAnnotatable)EntityType).IsInModel;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public virtual InternalEntityTypeMappingFragmentBuilder Builder
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool IsInModel
=> _builder is not null;
=> _builder is not null
&& ((IConventionAnnotatable)EntityType).IsInModel;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public virtual InternalRelationalPropertyOverridesBuilder Builder
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool IsInModel
=> _builder is not null;
=> _builder is not null
&& ((IConventionAnnotatable)Property).IsInModel;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public virtual InternalStoredProcedureParameterBuilder Builder
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool IsInModel
=> _builder is not null;
=> _builder is not null
&& StoredProcedure.IsInModel;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public virtual InternalStoredProcedureResultColumnBuilder Builder
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool IsInModel
=> _builder is not null;
=> _builder is not null
&& StoredProcedure.IsInModel;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down
1 change: 0 additions & 1 deletion src/EFCore/Metadata/Conventions/ModelCleanupConvention.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public virtual void ProcessForeignKeyRemoved(
{
var principalKey = foreignKey.PrincipalKey;
if (principalKey.IsInModel
&& principalKey.DeclaringEntityType.IsInModel
&& !principalKey.IsPrimaryKey()
&& !principalKey.GetReferencingForeignKeys().Any())
{
Expand Down
3 changes: 2 additions & 1 deletion src/EFCore/Metadata/Internal/ForeignKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ public virtual InternalForeignKeyBuilder Builder
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool IsInModel
=> _builder is not null;
=> _builder is not null
&& DeclaringEntityType.IsInModel;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down
3 changes: 2 additions & 1 deletion src/EFCore/Metadata/Internal/Index.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ public virtual InternalIndexBuilder Builder
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool IsInModel
=> _builder is not null;
=> _builder is not null
&& DeclaringEntityType.IsInModel;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down
3 changes: 2 additions & 1 deletion src/EFCore/Metadata/Internal/Key.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public virtual InternalKeyBuilder Builder
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool IsInModel
=> _builder is not null;
=> _builder is not null
&& DeclaringEntityType.IsInModel;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down
3 changes: 2 additions & 1 deletion src/EFCore/Metadata/Internal/Navigation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public virtual InternalNavigationBuilder Builder
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool IsInModel
=> _builder is not null;
=> _builder is not null
&& ForeignKey.IsInModel;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down
3 changes: 2 additions & 1 deletion src/EFCore/Metadata/Internal/Property.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ public virtual InternalPropertyBuilder Builder
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool IsInModel
=> _builder is not null;
=> _builder is not null
&& DeclaringEntityType.IsInModel;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down
3 changes: 2 additions & 1 deletion src/EFCore/Metadata/Internal/ServiceProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ public virtual InternalServicePropertyBuilder Builder
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool IsInModel
=> _builder is not null;
=> _builder is not null
&& DeclaringEntityType.IsInModel;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down
3 changes: 2 additions & 1 deletion src/EFCore/Metadata/Internal/SkipNavigation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public virtual InternalSkipNavigationBuilder Builder
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool IsInModel
=> _builder is not null;
=> _builder is not null
&& DeclaringEntityType.IsInModel;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down
3 changes: 2 additions & 1 deletion src/EFCore/Metadata/Internal/Trigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public virtual InternalTriggerBuilder Builder
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool IsInModel
=> _builder is not null;
=> _builder is not null
&& EntityType.IsInModel;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down

0 comments on commit 017e22e

Please sign in to comment.