diff --git a/src/EFCore/Diagnostics/CoreEventId.cs b/src/EFCore/Diagnostics/CoreEventId.cs
index 36cb4c8ded5..09c7fa839f8 100644
--- a/src/EFCore/Diagnostics/CoreEventId.cs
+++ b/src/EFCore/Diagnostics/CoreEventId.cs
@@ -66,6 +66,7 @@ private enum Id
QueryExecutionPlanned,
PossibleUnintendedCollectionNavigationNullComparisonWarning,
PossibleUnintendedReferenceComparisonWarning,
+ InvalidIncludePathError,
// Infrastructure events
SensitiveDataLoggingEnabledWarning = CoreBaseId + 400,
@@ -196,6 +197,20 @@ public static readonly EventId PossibleUnintendedCollectionNavigationNullCompari
public static readonly EventId PossibleUnintendedReferenceComparisonWarning
= MakeQueryId(Id.PossibleUnintendedReferenceComparisonWarning);
+ ///
+ ///
+ /// Invalid include path '{navigationChain}', couldn't find navigation for '{navigationName}'.
+ ///
+ ///
+ /// This event is in the category.
+ ///
+ ///
+ /// This event uses the payload when used with a .
+ ///
+ ///
+ public static readonly EventId InvalidIncludePathError
+ = MakeQueryId(Id.InvalidIncludePathError);
+
private static readonly string _infraPrefix = DbLoggerCategory.Infrastructure.Name + ".";
private static EventId MakeInfraId(Id id) => new EventId((int)id, _infraPrefix + id);
diff --git a/src/EFCore/Diagnostics/CoreLoggerExtensions.cs b/src/EFCore/Diagnostics/CoreLoggerExtensions.cs
index c9046172cdf..acbf40e86e6 100644
--- a/src/EFCore/Diagnostics/CoreLoggerExtensions.cs
+++ b/src/EFCore/Diagnostics/CoreLoggerExtensions.cs
@@ -531,7 +531,7 @@ public static void PossibleUnintendedReferenceComparisonWarning(
if (diagnostics.ShouldLog(definition))
{
- definition.Log(diagnostics,left, right);
+ definition.Log(diagnostics, left, right);
}
if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled))
@@ -553,6 +553,37 @@ private static string PossibleUnintendedReferenceComparisonWarning(EventDefiniti
return d.GenerateMessage(p.Left, p.Right);
}
+ public static void InvalidIncludePathError(
+ [NotNull] this IDiagnosticsLogger diagnostics,
+ [NotNull] string navigationChain,
+ [NotNull] string navigationName)
+ {
+ var definition = CoreResources.LogInvalidIncludePath(diagnostics);
+ if (diagnostics.ShouldLog(definition))
+ {
+ definition.Log(diagnostics, navigationChain, navigationName);
+ }
+
+ if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled))
+ {
+ var eventData = new InvalidIncludePathEventData(
+ definition,
+ InvalidIncludePathError,
+ navigationChain,
+ navigationName);
+
+ diagnostics.DispatchEventData(definition, eventData, diagnosticSourceEnabled, simpleLogEnabled);
+ }
+ }
+
+ private static string InvalidIncludePathError(EventDefinitionBase definition, EventData payload)
+ {
+ var d = (EventDefinition