Skip to content

Commit 066fee2

Browse files
committed
Throw when IsExcludedFromMigrations is executed on the runtime model
Leftover from #37815
1 parent 63f9baa commit 066fee2

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/EFCore.Relational/Extensions/RelationalForeignKeyExtensions.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,9 @@ static bool IsMapped(IReadOnlyForeignKey foreignKey, StoreObjectIdentifier store
295295
/// <param name="foreignKey">The foreign key.</param>
296296
/// <returns><see langword="true" /> if the foreign key constraint is excluded from migrations.</returns>
297297
public static bool IsExcludedFromMigrations(this IReadOnlyForeignKey foreignKey)
298-
=> (bool?)foreignKey[RelationalAnnotationNames.IsForeignKeyExcludedFromMigrations] ?? false;
298+
=> foreignKey is RuntimeForeignKey
299+
? throw new InvalidOperationException(CoreStrings.RuntimeModelMissingData)
300+
: (bool?)foreignKey[RelationalAnnotationNames.IsForeignKeyExcludedFromMigrations] ?? false;
299301

300302
/// <summary>
301303
/// Sets a value indicating whether the foreign key constraint is excluded from migrations.

0 commit comments

Comments
 (0)