System.Data.Entity.Internal.LazyInternalContext.OverrideConnection C# (CSharp) Method

OverrideConnection() public method

public OverrideConnection ( IInternalConnection connection ) : void
connection IInternalConnection
return void
        public override void OverrideConnection(IInternalConnection connection)
        {
            DebugCheck.NotNull(connection);

            // Connection should not be changed once context is initialized
            Debug.Assert(_creatingModel == false);
            Debug.Assert(_objectContext == null);

            connection.AppConfig = AppConfig;

            if (connection.ConnectionHasModel
                != _internalConnection.ConnectionHasModel)
            {
                throw _internalConnection.ConnectionHasModel
                          ? Error.LazyInternalContext_CannotReplaceEfConnectionWithDbConnection()
                          : Error.LazyInternalContext_CannotReplaceDbConnectionWithEfConnection();
            }

            _internalConnection.Dispose();

            _internalConnection = connection;
        }