EF.Toolkits.CustomSql.Triggers
1.0.11-alpha
See the version list below for details.
dotnet add package EF.Toolkits.CustomSql.Triggers --version 1.0.11-alpha
NuGet\Install-Package EF.Toolkits.CustomSql.Triggers -Version 1.0.11-alpha
<PackageReference Include="EF.Toolkits.CustomSql.Triggers" Version="1.0.11-alpha" />
paket add EF.Toolkits.CustomSql.Triggers --version 1.0.11-alpha
#r "nuget: EF.Toolkits.CustomSql.Triggers, 1.0.11-alpha"
// Install EF.Toolkits.CustomSql.Triggers as a Cake Addin #addin nuget:?package=EF.Toolkits.CustomSql.Triggers&version=1.0.11-alpha&prerelease // Install EF.Toolkits.CustomSql.Triggers as a Cake Tool #tool nuget:?package=EF.Toolkits.CustomSql.Triggers&version=1.0.11-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 | Versions 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. |
-
net5.0
- EF.Toolkits.CustomSql (>= 1.0.11-alpha)
- EF.Toolkits.Shared (>= 1.0.1-alpha)
-
net6.0
- EF.Toolkits.CustomSql (>= 1.0.11-alpha)
- EF.Toolkits.Shared (>= 1.0.1-alpha)
-
net7.0
- EF.Toolkits.CustomSql (>= 1.0.11-alpha)
- EF.Toolkits.Shared (>= 1.0.1-alpha)
-
net8.0
- EF.Toolkits.CustomSql (>= 1.0.11-alpha)
- EF.Toolkits.Shared (>= 1.0.1-alpha)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on EF.Toolkits.CustomSql.Triggers:
Package | Downloads |
---|---|
EF.Toolkits.CustomSql.Triggers.Postgresql
Managing the creation of triggers in the database postgresql through the EF migration mechanism. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.16-alpha | 36 | 11/20/2024 |
1.0.15-alpha | 101 | 10/24/2024 |
1.0.14-alpha | 37 | 10/24/2024 |
1.0.13-alpha | 38 | 10/24/2024 |
1.0.12-alpha | 120 | 10/18/2024 |
1.0.11-alpha | 41 | 10/17/2024 |
1.0.10-alpha | 53 | 10/16/2024 |
1.0.9-alpha | 45 | 10/14/2024 |
1.0.8-alpha | 47 | 10/14/2024 |
1.0.4-alpha | 53 | 10/12/2024 |
1.0.3-alpha | 51 | 10/12/2024 |
Creating Insert, Update, and Delete Triggers via DbContext