src/Shared/EntityFramework/Infrastructure/DbContextInfo.cs
/// <summary>
/// If instances of the underlying <see cref="DbContext" /> type can be created, returns
/// a new instance; otherwise returns null.
/// </summary>
/// <returns>
/// A <see cref="DbContext" /> instance.
/// </returns>
If instances of the underlying  type can be created, returns
a new instance; otherwise returns null.
If instances of the underlying type can be created returns a new instance ; otherwise returns null .
public virtual DbContext CreateInstance()
        {
            var configPushed = DbConfigurationManager.Instance.PushConfiguration(_appConfig, _contextType);
            CurrentInfo = this;
            DbContext context = null;
            try
            {
                try
                {
                    context = _activator == null ? null : _activator();
                }
                catch (TargetInvocationException ex)
                {
                    Debug.Assert(ex.InnerException != null);
#if !NET40
                    ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
#endif
                    throw ex.InnerException;
                }
                if (context == null)
                {
                    return null;
                }
                context.InternalContext.OnDisposing += (_, __) => CurrentInfo = null;
                if (configPushed)
                {
                    context.InternalContext.OnDisposing +=
                        (_, __) => DbConfigurationManager.Instance.PopConfiguration(_appConfig);
                }
                context.InternalContext.ApplyContextInfo(this);
                return context;
            }
            catch (Exception)
            {
                if (context != null)
                {
                    context.Dispose();
                }
                throw;
            }
            finally
            {
                if (context == null)
                {
                    CurrentInfo = null;
                    if (configPushed)
                    {
                        DbConfigurationManager.Instance.PopConfiguration(_appConfig);
                    }
                }
            }
        }
public virtual DbContext CreateInstance ( ) { var configPushed = DbConfigurationManager . Instance . PushConfiguration ( _appConfig , _contextType ) ; CurrentInfo = this ; DbContext context = null ; try { try { context = _activator == null ? null : _activator ( ) ; } catch ( TargetInvocationException ex ) { Debug . Assert ( ex . InnerException != null ) ; if ! NET40 ExceptionDispatchInfo . Capture ( ex . InnerException ) . Throw ( ) ; endif throw ex . InnerException ; } if ( context == null ) { return null ; } context . InternalContext . OnDisposing += ( _ , __ ) => CurrentInfo = null ; if ( configPushed ) { context . InternalContext . OnDisposing += ( _ , __ ) => DbConfigurationManager . Instance . PopConfiguration ( _appConfig ) ; } context . InternalContext . ApplyContextInfo ( this ) ; return context ; } catch ( Exception ) { if ( context != null ) { context . Dispose ( ) ; } throw ; } finally { if ( context == null ) { CurrentInfo = null ; if ( configPushed ) { DbConfigurationManager . Instance . PopConfiguration ( _appConfig ) ; } } } }
If instances of the underlying  type can be created, returns
a new instance; otherwise returns null.
If instances of the underlying type can be created returns a new instance ; otherwise returns null .
None