public static Type DetermineDbContextType(IChain chain, IContainer container)
        {
            var contextTypes = chain.ServiceDependencies(container).Where(x => x.CanBeCastTo <DbContext>()).ToArray();

            if (contextTypes.Length == 0)
            {
                throw new InvalidOperationException($"Cannot determine the {nameof(DbContext)} type for {chain.Description}");
            }

            if (contextTypes.Length > 1)
            {
                throw new InvalidOperationException(
                          $"Cannot determine the {nameof(DbContext)} type for {chain.Description}, multiple {nameof(DbContext)} types detected: {contextTypes.Select(x => x.Name).Join(", ")}");
            }

            return(contextTypes.Single());
        }