Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,9 @@ static bool IsMapped(IReadOnlyForeignKey foreignKey, StoreObjectIdentifier store
/// <param name="foreignKey">The foreign key.</param>
/// <returns><see langword="true" /> if the foreign key constraint is excluded from migrations.</returns>
public static bool IsExcludedFromMigrations(this IReadOnlyForeignKey foreignKey)
=> (bool?)foreignKey[RelationalAnnotationNames.IsForeignKeyExcludedFromMigrations] ?? false;
=> foreignKey is RuntimeForeignKey
? throw new InvalidOperationException(CoreStrings.RuntimeModelMissingData)
: (bool?)foreignKey[RelationalAnnotationNames.IsForeignKeyExcludedFromMigrations] ?? false;
Comment thread
roji marked this conversation as resolved.

/// <summary>
/// Sets a value indicating whether the foreign key constraint is excluded from migrations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,10 @@ protected override void AssertBigModel(IModel model, bool jsonColumns)

var dependentNavigation = principalDerived.GetDeclaredNavigations().First();
var dependentForeignKey = dependentNavigation.ForeignKey;
Assert.False(dependentForeignKey.IsExcludedFromMigrations());
Assert.Null(dependentForeignKey[RelationalAnnotationNames.IsForeignKeyExcludedFromMigrations]);
Assert.Equal(
CoreStrings.RuntimeModelMissingData,
Assert.Throws<InvalidOperationException>(() => dependentForeignKey.IsExcludedFromMigrations()).Message);

var referenceOwnedNavigation = principalBase.GetNavigations().Single();
var referenceOwnedType = referenceOwnedNavigation.TargetEntityType;
Expand Down
Loading