diff --git a/src/Microsoft.EntityFrameworkCore.Relational/Query/Internal/AsyncGroupJoinInclude.cs b/src/Microsoft.EntityFrameworkCore.Relational/Query/Internal/AsyncGroupJoinInclude.cs index 0950bd8c563..526d8dfeab7 100644 --- a/src/Microsoft.EntityFrameworkCore.Relational/Query/Internal/AsyncGroupJoinInclude.cs +++ b/src/Microsoft.EntityFrameworkCore.Relational/Query/Internal/AsyncGroupJoinInclude.cs @@ -61,7 +61,7 @@ public virtual void SetPrevious([NotNull] AsyncGroupJoinInclude previous) "This method is obsolete and will be removed in the 1.1.0 release. Use CreateIncludeContext instead.", error: true)] public virtual void Initialize([NotNull] RelationalQueryContext queryContext) - => CreateIncludeContext(queryContext); + => _currentContext = CreateIncludeContext(queryContext); /// /// This API supports the Entity Framework Core infrastructure and is not intended to be used @@ -81,7 +81,7 @@ var asyncGroupJoinIncludeContext asyncGroupJoinIncludeContext.SetPrevious(_previous.CreateIncludeContext(queryContext)); } - return _currentContext = asyncGroupJoinIncludeContext; + return asyncGroupJoinIncludeContext; } /// @@ -92,7 +92,7 @@ var asyncGroupJoinIncludeContext "This method is obsolete and will be removed in the 1.1.0 release. Use IncludeAsync on the object returned by CreateIncludeContext instead.", error: true)] public virtual Task IncludeAsync([CanBeNull] object entity, CancellationToken cancellationToken) - => _currentContext.IncludeAsync(entity, cancellationToken); + => _currentContext?.IncludeAsync(entity, cancellationToken) ?? Task.FromResult(0); /// /// This API supports the Entity Framework Core infrastructure and is not intended to be used diff --git a/src/Microsoft.EntityFrameworkCore.Relational/Query/Internal/GroupJoinInclude.cs b/src/Microsoft.EntityFrameworkCore.Relational/Query/Internal/GroupJoinInclude.cs index ffbb9ea09e8..3f8b7debdcc 100644 --- a/src/Microsoft.EntityFrameworkCore.Relational/Query/Internal/GroupJoinInclude.cs +++ b/src/Microsoft.EntityFrameworkCore.Relational/Query/Internal/GroupJoinInclude.cs @@ -60,7 +60,7 @@ public virtual void SetPrevious([NotNull] GroupJoinInclude previous) "This method is obsolete and will be removed in the 1.1.0 release. Use CreateIncludeContext instead.", error: true)] public virtual void Initialize([NotNull] RelationalQueryContext queryContext) - => CreateIncludeContext(queryContext); + => _currentContext = CreateIncludeContext(queryContext); /// /// This API supports the Entity Framework Core infrastructure and is not intended to be used @@ -80,7 +80,7 @@ var groupJoinIncludeContext groupJoinIncludeContext.SetPrevious(_previous.CreateIncludeContext(queryContext)); } - return _currentContext = groupJoinIncludeContext; + return groupJoinIncludeContext; } /// @@ -91,7 +91,7 @@ var groupJoinIncludeContext "This method is obsolete and will be removed in the 1.1.0 release. Use Include on the object returned by CreateIncludeContext instead.", error: true)] public virtual void Include([CanBeNull] object entity) - => _currentContext.Include(entity); + => _currentContext?.Include(entity); /// /// This API supports the Entity Framework Core infrastructure and is not intended to be used