EF.Toolkits.AutoComments 1.0.3-alpha

This is a prerelease version of EF.Toolkits.AutoComments.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package EF.Toolkits.AutoComments --version 1.0.3-alpha                
NuGet\Install-Package EF.Toolkits.AutoComments -Version 1.0.3-alpha                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EF.Toolkits.AutoComments" Version="1.0.3-alpha" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EF.Toolkits.AutoComments --version 1.0.3-alpha                
#r "nuget: EF.Toolkits.AutoComments, 1.0.3-alpha"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install EF.Toolkits.AutoComments as a Cake Addin
#addin nuget:?package=EF.Toolkits.AutoComments&version=1.0.3-alpha&prerelease

// Install EF.Toolkits.AutoComments as a Cake Tool
#tool nuget:?package=EF.Toolkits.AutoComments&version=1.0.3-alpha&prerelease                

EF.Toolkits

Данный проект содержит библиотеки для расширения возмжностей EF Core

Регистрация

optionsBuilder
    .UseNpgsql("Host=localhost;Port=5432;Database=EF.Toolkits.Tests;Username=postgres;Password=****")
    .UseCustomSql(options => options.UseTriggers())
    .UseAutoComments("Comments.xml");

EF.Toolkits.AutoComments

На основе файлов документации позволяет автоматически добавлять комментарии к столбцам и таблицам. Также поддерживает описание значений Enum через атрибут AutoCommentsEnumValues. В проект необходимо добавить генерацию файла документации и указать его имя при подключении расширения.

    <PropertyGroup>
        <GenerateDocumentationFile>true</GenerateDocumentationFile>
        <DocumentationFile>Comments.xml</DocumentationFile>
    </PropertyGroup>

EF.Toolkits.CustomSql

Добавляет возможность автоматически добавлять пользовательский SQL в код миграции с поддержкой изменения. Для каждого пользовательского SQL необхдимо определить 2 скрипта: на создание (Up) и на удаление (Down). Соответствующие скрипты попадут в файл миграции. В начало ммиграции добавляются скрпты для удаления, в конце миграции на добавление.

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder
        .AddCustomSql("animals_view", "SELECT * FROM animals a WHERE a.type = 1", "DROP VIEW  IF EXISTS animals_view");
}
EF.Toolkits.CustomSql.Triggers.Postgresql

Провайдер для автоматического добавления триггеров. Зависит от EF.Toolkits.CustomSql

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<Figure>(entity =>
   {
       entity.BeforeInsert("set_square", "new.square = 0");

       entity.BeforeUpdate("prevent_update_with_negative_square", "IF new.square < 0 THEN raise exception 'square negative' END IF;");
    });
}

Пример файла миграции

    public partial class Initial : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.Sql("SELECT * FROM animals a WHERE a.type = 1");

            migrationBuilder.Sql("CREATE FUNCTION prevent_update_with_negative_square() RETURNS trigger as $prevent_update_with_negative_square$\r\nBEGIN\r\nIF new.square < 0 THEN raise exception 'square negative' END IF;\r\nRETURN NEW;\r\nEND;\r\n$prevent_update_with_negative_square$ LANGUAGE plpgsql;\r\n\r\nCREATE TRIGGER prevent_update_with_negative_square BEFORE UPDATE\r\nON Figures\r\nFOR EACH ROW EXECUTE PROCEDURE prevent_update_with_negative_square();\r\n");

            migrationBuilder.Sql("CREATE FUNCTION set_square() RETURNS trigger as $set_square$\r\nBEGIN\r\nnew.square = 0\r\nRETURN NEW;\r\nEND;\r\n$set_square$ LANGUAGE plpgsql;\r\n\r\nCREATE TRIGGER set_square BEFORE INSERT\r\nON Figures\r\nFOR EACH ROW EXECUTE PROCEDURE set_square();\r\n");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.Sql("DROP VIEW  IF EXISTS animals_view");

            migrationBuilder.Sql("DROP FUNCTION prevent_update_with_negative_square() CASCADE;");

            migrationBuilder.Sql("DROP FUNCTION set_square() CASCADE;");
        }
    }
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net5.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.16-alpha 37 11/20/2024
1.0.15-alpha 114 10/24/2024
1.0.14-alpha 35 10/24/2024
1.0.13-alpha 39 10/24/2024
1.0.12-alpha 111 10/18/2024
1.0.11-alpha 37 10/17/2024
1.0.10-alpha 40 10/16/2024
1.0.9-alpha 47 10/14/2024
1.0.8-alpha 42 10/14/2024
1.0.7-alpha 47 10/14/2024
1.0.5-alpha 43 10/14/2024
1.0.4-alpha 45 10/12/2024
1.0.3-alpha 47 10/12/2024
1.0.2-alpha 48 10/12/2024
1.0.1-alpha 47 10/12/2024

Automatically add comments to columns and tables