Exemplo n.º 1
0
    /// <summary>
    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
    ///     any release. You should only use it directly in your code with extreme caution and knowing that
    ///     doing so can result in application failures when updating to a new Entity Framework Core release.
    /// </summary>
    public virtual void DropDatabase(string?contextType)
    {
        using var context = CreateContext(contextType);
        var connection = context.Database.GetDbConnection();

        _reporter.WriteInformation(DesignStrings.DroppingDatabase(connection.Database, connection.DataSource));
        _reporter.WriteInformation(
            context.Database.EnsureDeleted()
                ? DesignStrings.DatabaseDropped(connection.Database)
                : DesignStrings.NotExistDatabase(connection.Database));
    }
        /// <summary>
        ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
        ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
        ///     any release. You should only use it directly in your code with extreme caution and knowing that
        ///     doing so can result in application failures when updating to a new Entity Framework Core release.
        /// </summary>
        public virtual void DropDatabase([CanBeNull] string contextType)
        {
            using var context = CreateContext(contextType);
            var connection = context.Database.GetDbConnection();

            _reporter.WriteInformation(DesignStrings.DroppingDatabase(connection.Database));
            if (context.Database.EnsureDeleted())
            {
                _reporter.WriteInformation(DesignStrings.DatabaseDropped(connection.Database));
            }
            else
            {
                _reporter.WriteInformation(DesignStrings.NotExistDatabase(connection.Database));
            }
        }