コード例 #1
0
    /// <summary>
    /// Registers a PostgreSQL extension in the model.
    /// </summary>
    /// <param name="modelBuilder">The model builder in which to define the extension.</param>
    /// <param name="schema">The schema in which to create the extension.</param>
    /// <param name="name">The name of the extension to create.</param>
    /// <param name="version">The version of the extension.</param>
    /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
    /// <returns>The same builder instance so that multiple calls can be chained.</returns>
    /// <remarks>
    /// See: https://www.postgresql.org/docs/current/external-extensions.html
    /// </remarks>
    /// <exception cref="ArgumentNullException"><paramref name="modelBuilder"/></exception>
    public static IConventionModelBuilder?HasPostgresExtension(
        this IConventionModelBuilder modelBuilder,
        string?schema,
        string name,
        string?version          = null,
        bool fromDataAnnotation = false)
    {
        if (modelBuilder.CanSetPostgresExtension(schema, name, version, fromDataAnnotation))
        {
            modelBuilder.Metadata.GetOrAddPostgresExtension(schema, name, version);
            return(modelBuilder);
        }

        return(null);
    }