I'm reading "Building Web Applications with Visual Studio 2017" (by Philip Japikse, Kevin Grossnicklaus, and Ben Dewey) and am getting stuck. When trying to create a class for a custome execution strategy with Entity Framework Core I get error CR0246 "The type or namespace name 'ExecutionStrategyContext' could not be found (are you missing a using directive or assembly reference?)"
The text only states that only System and Microsoft.EntityFrameworkCore.Storage are required references. The EF Core 2.0 documentation seems to match the text but I cannot get the error to go away.
Note: The book uses Core and EF 1.1 whereas I am using 2.0. But I don't see anything in any documentation that hints at this being the issue. The class is:
using System;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore;
namespace SpyStore.DAL.EF
{
public class MyExecutionStrategy : ExecutionStrategy
{
public MyExecutionStrategy(ExecutionStrategyContext context) :
base(context, ExecutionStrategy.DefaultMaxRetryCount, ExecutionStrategy.DefaultMaxDelay)
{
}
public MyExecutionStrategy(ExecutionStrategyContext context, int maxRetryCount, TimeSpan maxRetryDelay) :
base(context, maxRetryCount, maxRetryDelay)
{
}
protected override bool ShouldRetryOn(Exception exception)
{
return true;
}
}
}
VS2017 is highlighting both instances of ExecutionStrategyContext as the issue. I've tried changing them to just 'ExecutionStrategy context' instead of 'ExecutionStrategyContext context' but I don't think this is what I want and I still get an error because my first parameter is context. Any help is appreciated! Thanks!
I can't provide a documentation link because at this time the related EF Core API documentation is not updated yet, but in v2.0 the
ExecutionStrategyContext
class has been replaced withExecutionStrategyDependencies
and theExecutionStrategy
class now has the following constructors:According to that, the updated sample should be something like this: