/// <summary>
        /// Returns the handler for the requested entity.
        /// </summary>
        /// <typeparam name="TContext">The type of context.</typeparam>
        /// <param name="entityType">The type of an entity known to the context.</param>
        /// <param name="entityIdentifier">The key of the entity.</param>
        /// <returns></returns>
        public static EntityGateContext <TContext> GetEntityGate <TContext>(Type entityType, object entityIdentifier) where TContext : DbContext
        {
            var speedEntityInstance = ReflectionHelper.MakeInstance <IEntityObjectIdentifier>(entityType);
            var gate = new EntityGateContext <TContext>(speedEntityInstance);

            if (!gate.Load(entityIdentifier))
            {
                throw new EntityGateCoreException(string.Format(CultureInfo.InvariantCulture, Resources.UnableToLoadEntityKey, gate.GetFriendlyName(), entityIdentifier != null ? entityIdentifier.ToString() : "null"));
            }

            return(gate);
        }
        /// <summary>
        /// Returns the handler for the requested entity.
        /// </summary>
        /// <typeparam name="TContext">The type of context.</typeparam>
        /// <param name="component">An instance of an entity.</param>
        /// <returns></returns>
        public static EntityGateContext <TContext> GetEntityGate <TContext>(ref IEntityObjectIdentifier component) where TContext : DbContext
        {
            var gate = new EntityGateContext <TContext>(component);

            if (!gate.IsNewEntity)
            {
                gate.Load();
            }

            component = gate.Entity;

            return(gate);
        }