diff --git a/.gitignore b/.gitignore
index cd628b7..d618a7d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -353,4 +353,7 @@ MigrationBackup/
/PoC
# Docs local build
-/docs/_site
\ No newline at end of file
+/docs/_site
+
+# Integration test migration files - these will be scaffolded by the CI pipeline
+/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/*/Persistence/Migrations
diff --git a/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangeSourceEntity/Persistence/Migrations/20241023092650_Initial.Designer.cs b/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangeSourceEntity/Persistence/Migrations/20241023092650_Initial.Designer.cs
deleted file mode 100644
index 3a5bbac..0000000
--- a/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangeSourceEntity/Persistence/Migrations/20241023092650_Initial.Designer.cs
+++ /dev/null
@@ -1,208 +0,0 @@
-//
-using System;
-using EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangeSourceEntity.Persistence;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangeSourceEntity.Persistence.Migrations
-{
- [DbContext(typeof(ChangeSourceEntityDbContext))]
- [Migration("20241023092650_Initial")]
- partial class Initial
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "8.0.8")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
-
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
-
- modelBuilder.Entity("EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangeSourceEntity.Domain.ChangeSource", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("Name")
- .HasColumnType("nvarchar(max)");
-
- b.HasKey("Id");
-
- b.ToTable("ChangeSources");
-
- b.HasData(
- new
- {
- Id = 1,
- Name = "Migrations"
- },
- new
- {
- Id = 2,
- Name = "Tests"
- },
- new
- {
- Id = 3,
- Name = "Web API"
- },
- new
- {
- Id = 4,
- Name = "Console"
- },
- new
- {
- Id = 5,
- Name = "SQL"
- },
- new
- {
- Id = 6,
- Name = "Mobile"
- },
- new
- {
- Id = 7,
- Name = "Public API"
- },
- new
- {
- Id = 8,
- Name = "Email Service"
- },
- new
- {
- Id = 9,
- Name = "Data Retention Service"
- },
- new
- {
- Id = 10,
- Name = "Maintenance"
- });
- });
-
- modelBuilder.Entity("EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangeSourceEntity.Domain.ChangeSourceEntityUser", b =>
- {
- b.Property("Id")
- .HasColumnType("int");
-
- b.Property("Username")
- .HasColumnType("nvarchar(max)");
-
- b.HasKey("Id");
-
- b.ToTable("TestUsers", t =>
- {
- t.HasTrigger("ChangeTrigger");
- });
-
- b
- .HasAnnotation("ChangeTriggers:HasChangeTrigger", true)
- .HasAnnotation("SqlServer:UseSqlOutputClause", false);
-
- b.HasData(
- new
- {
- Id = 0,
- Username = "System"
- },
- new
- {
- Id = 100,
- Username = "TestUser100"
- },
- new
- {
- Id = 101,
- Username = "TestUser101"
- },
- new
- {
- Id = 102,
- Username = "TestUser102"
- },
- new
- {
- Id = 103,
- Username = "TestUser103"
- });
- });
-
- modelBuilder.Entity("EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangeSourceEntity.Domain.ChangeSourceEntityUserChange", b =>
- {
- b.Property("ChangeId")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ChangeId"));
-
- b.Property("ChangeSourceId")
- .HasColumnType("int");
-
- b.Property("ChangedAt")
- .HasColumnType("datetimeoffset")
- .HasAnnotation("ChangeTriggers:IsChangedAtColumn", true);
-
- b.Property("Id")
- .HasColumnType("int");
-
- b.Property("OperationType")
- .HasColumnType("int")
- .HasColumnName("OperationTypeId")
- .HasAnnotation("ChangeTriggers:IsOperationTypeColumn", true);
-
- b.Property("Username")
- .HasColumnType("nvarchar(max)");
-
- b.HasKey("ChangeId");
-
- b.HasIndex("ChangeSourceId");
-
- b.HasIndex("Id");
-
- b.ToTable("TestUserChanges");
-
- b
- .HasAnnotation("ChangeTriggers:HasChangeSource", true)
- .HasAnnotation("ChangeTriggers:IsChangeTable", true);
- });
-
- modelBuilder.Entity("EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangeSourceEntity.Domain.ChangeSourceEntityUserChange", b =>
- {
- b.HasOne("EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangeSourceEntity.Domain.ChangeSource", "ChangeSource")
- .WithMany()
- .HasForeignKey("ChangeSourceId")
- .HasAnnotation("ChangeTriggers:HasNoCheckConstraint", true)
- .HasAnnotation("ChangeTriggers:IsChangeSourceColumn", true);
-
- b.HasOne("EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangeSourceEntity.Domain.ChangeSourceEntityUser", "TrackedEntity")
- .WithMany("Changes")
- .HasForeignKey("Id")
- .HasAnnotation("ChangeTriggers:HasNoCheckConstraint", true)
- .HasAnnotation("ChangeTriggers:IsTrackedEntityForeignKey", true);
-
- b.Navigation("ChangeSource");
-
- b.Navigation("TrackedEntity");
- });
-
- modelBuilder.Entity("EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangeSourceEntity.Domain.ChangeSourceEntityUser", b =>
- {
- b.Navigation("Changes");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangeSourceEntity/Persistence/Migrations/20241023092650_Initial.cs b/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangeSourceEntity/Persistence/Migrations/20241023092650_Initial.cs
deleted file mode 100644
index 2c6793a..0000000
--- a/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangeSourceEntity/Persistence/Migrations/20241023092650_Initial.cs
+++ /dev/null
@@ -1,143 +0,0 @@
-using System;
-using EFCore.ChangeTriggers.Migrations.Operations;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
-
-namespace EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangeSourceEntity.Persistence.Migrations
-{
- ///
- public partial class Initial : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "ChangeSources",
- columns: table => new
- {
- Id = table.Column(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- Name = table.Column(type: "nvarchar(max)", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_ChangeSources", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "TestUsers",
- columns: table => new
- {
- Id = table.Column(type: "int", nullable: false),
- Username = table.Column(type: "nvarchar(max)", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_TestUsers", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "TestUserChanges",
- columns: table => new
- {
- ChangeId = table.Column(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- Id = table.Column(type: "int", nullable: false),
- Username = table.Column(type: "nvarchar(max)", nullable: true),
- OperationTypeId = table.Column(type: "int", nullable: false),
- ChangedAt = table.Column(type: "datetimeoffset", nullable: false),
- ChangeSourceId = table.Column(type: "int", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_TestUserChanges", x => x.ChangeId);
- table.ForeignKey(
- name: "FK_TestUserChanges_ChangeSources_ChangeSourceId",
- column: x => x.ChangeSourceId,
- principalTable: "ChangeSources",
- principalColumn: "Id");
- table.ForeignKey(
- name: "FK_TestUserChanges_TestUsers_Id",
- column: x => x.Id,
- principalTable: "TestUsers",
- principalColumn: "Id");
- });
-
- migrationBuilder.AddNoCheckConstraint(
- table: "TestUserChanges",
- constraint: "FK_TestUserChanges_ChangeSources_ChangeSourceId");
-
- migrationBuilder.AddNoCheckConstraint(
- table: "TestUserChanges",
- constraint: "FK_TestUserChanges_TestUsers_Id");
-
- migrationBuilder.CreateChangeTrigger(
- trackedTableName: "TestUsers",
- changeTableName: "TestUserChanges",
- triggerName: "TestUsers_ChangeTrigger",
- trackedTablePrimaryKeyColumns: new[] { "Id" },
- changeTableDataColumns: new[] { "Id", "Username" },
- operationTypeColumn: new ChangeContextColumn("OperationTypeId", "int"),
- changedAtColumn: new ChangeContextColumn("ChangedAt"),
- changeSourceColumn: new ChangeContextColumn("ChangeSourceId", "int"));
-
- migrationBuilder.InsertData(
- table: "ChangeSources",
- columns: new[] { "Id", "Name" },
- values: new object[,]
- {
- { 1, "Migrations" },
- { 2, "Tests" },
- { 3, "Web API" },
- { 4, "Console" },
- { 5, "SQL" },
- { 6, "Mobile" },
- { 7, "Public API" },
- { 8, "Email Service" },
- { 9, "Data Retention Service" },
- { 10, "Maintenance" }
- });
-
- migrationBuilder.InsertData(
- table: "TestUsers",
- columns: new[] { "Id", "Username" },
- values: new object[,]
- {
- { 0, "System" },
- { 100, "TestUser100" },
- { 101, "TestUser101" },
- { 102, "TestUser102" },
- { 103, "TestUser103" }
- });
-
- migrationBuilder.CreateIndex(
- name: "IX_TestUserChanges_ChangeSourceId",
- table: "TestUserChanges",
- column: "ChangeSourceId");
-
- migrationBuilder.CreateIndex(
- name: "IX_TestUserChanges_Id",
- table: "TestUserChanges",
- column: "Id");
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropChangeTrigger(
- triggerName: "TestUsers_ChangeTrigger");
-
- migrationBuilder.DropTable(
- name: "TestUserChanges");
-
- migrationBuilder.DropTable(
- name: "ChangeSources");
-
- migrationBuilder.DropTable(
- name: "TestUsers");
- }
- }
-}
diff --git a/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangeSourceScalar/Persistence/Migrations/20241023092654_Initial.Designer.cs b/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangeSourceScalar/Persistence/Migrations/20241023092654_Initial.Designer.cs
deleted file mode 100644
index 0e98a58..0000000
--- a/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangeSourceScalar/Persistence/Migrations/20241023092654_Initial.Designer.cs
+++ /dev/null
@@ -1,131 +0,0 @@
-//
-using System;
-using EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangeSourceScalar.Persistence;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangeSourceScalar.Persistence.Migrations
-{
- [DbContext(typeof(ChangeSourceScalarDbContext))]
- [Migration("20241023092654_Initial")]
- partial class Initial
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "8.0.8")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
-
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
-
- modelBuilder.Entity("EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangeSourceScalar.Domain.ChangeSourceScalarUser", b =>
- {
- b.Property("Id")
- .HasColumnType("int");
-
- b.Property("Username")
- .HasColumnType("nvarchar(max)");
-
- b.HasKey("Id");
-
- b.ToTable("TestUsers", t =>
- {
- t.HasTrigger("ChangeTrigger");
- });
-
- b
- .HasAnnotation("ChangeTriggers:HasChangeTrigger", true)
- .HasAnnotation("SqlServer:UseSqlOutputClause", false);
-
- b.HasData(
- new
- {
- Id = 0,
- Username = "System"
- },
- new
- {
- Id = 100,
- Username = "TestUser100"
- },
- new
- {
- Id = 101,
- Username = "TestUser101"
- },
- new
- {
- Id = 102,
- Username = "TestUser102"
- },
- new
- {
- Id = 103,
- Username = "TestUser103"
- });
- });
-
- modelBuilder.Entity("EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangeSourceScalar.Domain.ChangeSourceScalarUserChange", b =>
- {
- b.Property("ChangeId")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ChangeId"));
-
- b.Property("ChangeSource")
- .HasColumnType("int")
- .HasAnnotation("ChangeTriggers:IsChangeSourceColumn", true);
-
- b.Property("ChangedAt")
- .HasColumnType("datetimeoffset")
- .HasAnnotation("ChangeTriggers:IsChangedAtColumn", true);
-
- b.Property("Id")
- .HasColumnType("int");
-
- b.Property("OperationType")
- .HasColumnType("int")
- .HasColumnName("OperationTypeId")
- .HasAnnotation("ChangeTriggers:IsOperationTypeColumn", true);
-
- b.Property("Username")
- .HasColumnType("nvarchar(max)");
-
- b.HasKey("ChangeId");
-
- b.HasIndex("Id");
-
- b.ToTable("TestUserChanges");
-
- b
- .HasAnnotation("ChangeTriggers:HasChangeSource", true)
- .HasAnnotation("ChangeTriggers:IsChangeTable", true);
- });
-
- modelBuilder.Entity("EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangeSourceScalar.Domain.ChangeSourceScalarUserChange", b =>
- {
- b.HasOne("EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangeSourceScalar.Domain.ChangeSourceScalarUser", "TrackedEntity")
- .WithMany("Changes")
- .HasForeignKey("Id")
- .HasAnnotation("ChangeTriggers:HasNoCheckConstraint", true)
- .HasAnnotation("ChangeTriggers:IsTrackedEntityForeignKey", true);
-
- b.Navigation("TrackedEntity");
- });
-
- modelBuilder.Entity("EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangeSourceScalar.Domain.ChangeSourceScalarUser", b =>
- {
- b.Navigation("Changes");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangeSourceScalar/Persistence/Migrations/20241023092654_Initial.cs b/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangeSourceScalar/Persistence/Migrations/20241023092654_Initial.cs
deleted file mode 100644
index aae0262..0000000
--- a/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangeSourceScalar/Persistence/Migrations/20241023092654_Initial.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-using System;
-using EFCore.ChangeTriggers.Migrations.Operations;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
-
-namespace EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangeSourceScalar.Persistence.Migrations
-{
- ///
- public partial class Initial : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "TestUsers",
- columns: table => new
- {
- Id = table.Column(type: "int", nullable: false),
- Username = table.Column(type: "nvarchar(max)", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_TestUsers", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "TestUserChanges",
- columns: table => new
- {
- ChangeId = table.Column(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- Id = table.Column(type: "int", nullable: false),
- Username = table.Column(type: "nvarchar(max)", nullable: true),
- OperationTypeId = table.Column(type: "int", nullable: false),
- ChangedAt = table.Column(type: "datetimeoffset", nullable: false),
- ChangeSource = table.Column(type: "int", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_TestUserChanges", x => x.ChangeId);
- table.ForeignKey(
- name: "FK_TestUserChanges_TestUsers_Id",
- column: x => x.Id,
- principalTable: "TestUsers",
- principalColumn: "Id");
- });
-
- migrationBuilder.AddNoCheckConstraint(
- table: "TestUserChanges",
- constraint: "FK_TestUserChanges_TestUsers_Id");
-
- migrationBuilder.CreateChangeTrigger(
- trackedTableName: "TestUsers",
- changeTableName: "TestUserChanges",
- triggerName: "TestUsers_ChangeTrigger",
- trackedTablePrimaryKeyColumns: new[] { "Id" },
- changeTableDataColumns: new[] { "Id", "Username" },
- operationTypeColumn: new ChangeContextColumn("OperationTypeId", "int"),
- changedAtColumn: new ChangeContextColumn("ChangedAt"),
- changeSourceColumn: new ChangeContextColumn("ChangeSource", "int"));
-
- migrationBuilder.InsertData(
- table: "TestUsers",
- columns: new[] { "Id", "Username" },
- values: new object[,]
- {
- { 0, "System" },
- { 100, "TestUser100" },
- { 101, "TestUser101" },
- { 102, "TestUser102" },
- { 103, "TestUser103" }
- });
-
- migrationBuilder.CreateIndex(
- name: "IX_TestUserChanges_Id",
- table: "TestUserChanges",
- column: "Id");
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropChangeTrigger(
- triggerName: "TestUsers_ChangeTrigger");
-
- migrationBuilder.DropTable(
- name: "TestUserChanges");
-
- migrationBuilder.DropTable(
- name: "TestUsers");
- }
- }
-}
diff --git a/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangedByEntity/Persistence/Migrations/20241023092642_Initial.Designer.cs b/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangedByEntity/Persistence/Migrations/20241023092642_Initial.Designer.cs
deleted file mode 100644
index ec85060..0000000
--- a/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangedByEntity/Persistence/Migrations/20241023092642_Initial.Designer.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-//
-using System;
-using EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangedByEntity.Persistence;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangedByEntity.Persistence.Migrations
-{
- [DbContext(typeof(ChangedByEntityDbContext))]
- [Migration("20241023092642_Initial")]
- partial class Initial
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "8.0.8")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
-
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
-
- modelBuilder.Entity("EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangedByEntity.Domain.ChangedByEntityUser", b =>
- {
- b.Property("Id")
- .HasColumnType("int");
-
- b.Property("Username")
- .HasColumnType("nvarchar(max)");
-
- b.HasKey("Id");
-
- b.ToTable("TestUsers", t =>
- {
- t.HasTrigger("ChangeTrigger");
- });
-
- b
- .HasAnnotation("ChangeTriggers:HasChangeTrigger", true)
- .HasAnnotation("SqlServer:UseSqlOutputClause", false);
-
- b.HasData(
- new
- {
- Id = 0,
- Username = "System"
- },
- new
- {
- Id = 100,
- Username = "TestUser100"
- },
- new
- {
- Id = 101,
- Username = "TestUser101"
- },
- new
- {
- Id = 102,
- Username = "TestUser102"
- },
- new
- {
- Id = 103,
- Username = "TestUser103"
- });
- });
-
- modelBuilder.Entity("EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangedByEntity.Domain.ChangedByEntityUserChange", b =>
- {
- b.Property("ChangeId")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ChangeId"));
-
- b.Property("ChangedAt")
- .HasColumnType("datetimeoffset")
- .HasAnnotation("ChangeTriggers:IsChangedAtColumn", true);
-
- b.Property("ChangedById")
- .HasColumnType("int");
-
- b.Property("Id")
- .HasColumnType("int");
-
- b.Property("OperationType")
- .HasColumnType("int")
- .HasColumnName("OperationTypeId")
- .HasAnnotation("ChangeTriggers:IsOperationTypeColumn", true);
-
- b.Property("Username")
- .HasColumnType("nvarchar(max)");
-
- b.HasKey("ChangeId");
-
- b.HasIndex("ChangedById");
-
- b.HasIndex("Id");
-
- b.ToTable("TestUserChanges");
-
- b
- .HasAnnotation("ChangeTriggers:HasChangedBy", true)
- .HasAnnotation("ChangeTriggers:IsChangeTable", true);
- });
-
- modelBuilder.Entity("EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangedByEntity.Domain.ChangedByEntityUserChange", b =>
- {
- b.HasOne("EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangedByEntity.Domain.ChangedByEntityUser", "ChangedBy")
- .WithMany()
- .HasForeignKey("ChangedById")
- .HasAnnotation("ChangeTriggers:HasNoCheckConstraint", true)
- .HasAnnotation("ChangeTriggers:IsChangedByColumn", true);
-
- b.HasOne("EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangedByEntity.Domain.ChangedByEntityUser", "TrackedEntity")
- .WithMany("Changes")
- .HasForeignKey("Id")
- .HasAnnotation("ChangeTriggers:HasNoCheckConstraint", true)
- .HasAnnotation("ChangeTriggers:IsTrackedEntityForeignKey", true);
-
- b.Navigation("ChangedBy");
-
- b.Navigation("TrackedEntity");
- });
-
- modelBuilder.Entity("EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangedByEntity.Domain.ChangedByEntityUser", b =>
- {
- b.Navigation("Changes");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangedByEntity/Persistence/Migrations/20241023092642_Initial.cs b/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangedByEntity/Persistence/Migrations/20241023092642_Initial.cs
deleted file mode 100644
index 292a0c3..0000000
--- a/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangedByEntity/Persistence/Migrations/20241023092642_Initial.cs
+++ /dev/null
@@ -1,110 +0,0 @@
-using System;
-using EFCore.ChangeTriggers.Migrations.Operations;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
-
-namespace EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangedByEntity.Persistence.Migrations
-{
- ///
- public partial class Initial : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "TestUsers",
- columns: table => new
- {
- Id = table.Column(type: "int", nullable: false),
- Username = table.Column(type: "nvarchar(max)", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_TestUsers", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "TestUserChanges",
- columns: table => new
- {
- ChangeId = table.Column(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- Id = table.Column(type: "int", nullable: false),
- Username = table.Column(type: "nvarchar(max)", nullable: true),
- OperationTypeId = table.Column(type: "int", nullable: false),
- ChangedAt = table.Column(type: "datetimeoffset", nullable: false),
- ChangedById = table.Column(type: "int", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_TestUserChanges", x => x.ChangeId);
- table.ForeignKey(
- name: "FK_TestUserChanges_TestUsers_ChangedById",
- column: x => x.ChangedById,
- principalTable: "TestUsers",
- principalColumn: "Id");
- table.ForeignKey(
- name: "FK_TestUserChanges_TestUsers_Id",
- column: x => x.Id,
- principalTable: "TestUsers",
- principalColumn: "Id");
- });
-
- migrationBuilder.AddNoCheckConstraint(
- table: "TestUserChanges",
- constraint: "FK_TestUserChanges_TestUsers_ChangedById");
-
- migrationBuilder.AddNoCheckConstraint(
- table: "TestUserChanges",
- constraint: "FK_TestUserChanges_TestUsers_Id");
-
- migrationBuilder.CreateChangeTrigger(
- trackedTableName: "TestUsers",
- changeTableName: "TestUserChanges",
- triggerName: "TestUsers_ChangeTrigger",
- trackedTablePrimaryKeyColumns: new[] { "Id" },
- changeTableDataColumns: new[] { "Id", "Username" },
- operationTypeColumn: new ChangeContextColumn("OperationTypeId", "int"),
- changedAtColumn: new ChangeContextColumn("ChangedAt"),
- changedByColumn: new ChangeContextColumn("ChangedById", "int"));
-
- migrationBuilder.InsertData(
- table: "TestUsers",
- columns: new[] { "Id", "Username" },
- values: new object[,]
- {
- { 0, "System" },
- { 100, "TestUser100" },
- { 101, "TestUser101" },
- { 102, "TestUser102" },
- { 103, "TestUser103" }
- });
-
- migrationBuilder.CreateIndex(
- name: "IX_TestUserChanges_ChangedById",
- table: "TestUserChanges",
- column: "ChangedById");
-
- migrationBuilder.CreateIndex(
- name: "IX_TestUserChanges_Id",
- table: "TestUserChanges",
- column: "Id");
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropChangeTrigger(
- triggerName: "TestUsers_ChangeTrigger");
-
- migrationBuilder.DropTable(
- name: "TestUserChanges");
-
- migrationBuilder.DropTable(
- name: "TestUsers");
- }
- }
-}
diff --git a/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangedByScalar/Persistence/Migrations/20241023092646_Initial.Designer.cs b/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangedByScalar/Persistence/Migrations/20241023092646_Initial.Designer.cs
deleted file mode 100644
index 97bb249..0000000
--- a/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangedByScalar/Persistence/Migrations/20241023092646_Initial.Designer.cs
+++ /dev/null
@@ -1,131 +0,0 @@
-//
-using System;
-using EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangedByScalar.Persistence;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangedByScalar.Persistence.Migrations
-{
- [DbContext(typeof(ChangedByScalarDbContext))]
- [Migration("20241023092646_Initial")]
- partial class Initial
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "8.0.8")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
-
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
-
- modelBuilder.Entity("EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangedByScalar.Domain.ChangedByScalarUser", b =>
- {
- b.Property("Id")
- .HasColumnType("int");
-
- b.Property("Username")
- .HasColumnType("nvarchar(max)");
-
- b.HasKey("Id");
-
- b.ToTable("TestUsers", t =>
- {
- t.HasTrigger("ChangeTrigger");
- });
-
- b
- .HasAnnotation("ChangeTriggers:HasChangeTrigger", true)
- .HasAnnotation("SqlServer:UseSqlOutputClause", false);
-
- b.HasData(
- new
- {
- Id = 0,
- Username = "System"
- },
- new
- {
- Id = 100,
- Username = "TestUser100"
- },
- new
- {
- Id = 101,
- Username = "TestUser101"
- },
- new
- {
- Id = 102,
- Username = "TestUser102"
- },
- new
- {
- Id = 103,
- Username = "TestUser103"
- });
- });
-
- modelBuilder.Entity("EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangedByScalar.Domain.ChangedByScalarUserChange", b =>
- {
- b.Property("ChangeId")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ChangeId"));
-
- b.Property("ChangedAt")
- .HasColumnType("datetimeoffset")
- .HasAnnotation("ChangeTriggers:IsChangedAtColumn", true);
-
- b.Property("ChangedBy")
- .HasColumnType("nvarchar(max)")
- .HasAnnotation("ChangeTriggers:IsChangedByColumn", true);
-
- b.Property("Id")
- .HasColumnType("int");
-
- b.Property("OperationType")
- .HasColumnType("int")
- .HasColumnName("OperationTypeId")
- .HasAnnotation("ChangeTriggers:IsOperationTypeColumn", true);
-
- b.Property("Username")
- .HasColumnType("nvarchar(max)");
-
- b.HasKey("ChangeId");
-
- b.HasIndex("Id");
-
- b.ToTable("TestUserChanges");
-
- b
- .HasAnnotation("ChangeTriggers:HasChangedBy", true)
- .HasAnnotation("ChangeTriggers:IsChangeTable", true);
- });
-
- modelBuilder.Entity("EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangedByScalar.Domain.ChangedByScalarUserChange", b =>
- {
- b.HasOne("EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangedByScalar.Domain.ChangedByScalarUser", "TrackedEntity")
- .WithMany("Changes")
- .HasForeignKey("Id")
- .HasAnnotation("ChangeTriggers:HasNoCheckConstraint", true)
- .HasAnnotation("ChangeTriggers:IsTrackedEntityForeignKey", true);
-
- b.Navigation("TrackedEntity");
- });
-
- modelBuilder.Entity("EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangedByScalar.Domain.ChangedByScalarUser", b =>
- {
- b.Navigation("Changes");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangedByScalar/Persistence/Migrations/20241023092646_Initial.cs b/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangedByScalar/Persistence/Migrations/20241023092646_Initial.cs
deleted file mode 100644
index 7daeec2..0000000
--- a/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/ChangedByScalar/Persistence/Migrations/20241023092646_Initial.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-using System;
-using EFCore.ChangeTriggers.Migrations.Operations;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
-
-namespace EFCore.ChangeTriggers.SqlServer.Tests.Integration.ChangedByScalar.Persistence.Migrations
-{
- ///
- public partial class Initial : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "TestUsers",
- columns: table => new
- {
- Id = table.Column(type: "int", nullable: false),
- Username = table.Column(type: "nvarchar(max)", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_TestUsers", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "TestUserChanges",
- columns: table => new
- {
- ChangeId = table.Column(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- Id = table.Column(type: "int", nullable: false),
- Username = table.Column(type: "nvarchar(max)", nullable: true),
- OperationTypeId = table.Column(type: "int", nullable: false),
- ChangedAt = table.Column(type: "datetimeoffset", nullable: false),
- ChangedBy = table.Column(type: "nvarchar(max)", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_TestUserChanges", x => x.ChangeId);
- table.ForeignKey(
- name: "FK_TestUserChanges_TestUsers_Id",
- column: x => x.Id,
- principalTable: "TestUsers",
- principalColumn: "Id");
- });
-
- migrationBuilder.AddNoCheckConstraint(
- table: "TestUserChanges",
- constraint: "FK_TestUserChanges_TestUsers_Id");
-
- migrationBuilder.CreateChangeTrigger(
- trackedTableName: "TestUsers",
- changeTableName: "TestUserChanges",
- triggerName: "TestUsers_ChangeTrigger",
- trackedTablePrimaryKeyColumns: new[] { "Id" },
- changeTableDataColumns: new[] { "Id", "Username" },
- operationTypeColumn: new ChangeContextColumn("OperationTypeId", "int"),
- changedAtColumn: new ChangeContextColumn("ChangedAt"),
- changedByColumn: new ChangeContextColumn("ChangedBy", "nvarchar(max)"));
-
- migrationBuilder.InsertData(
- table: "TestUsers",
- columns: new[] { "Id", "Username" },
- values: new object[,]
- {
- { 0, "System" },
- { 100, "TestUser100" },
- { 101, "TestUser101" },
- { 102, "TestUser102" },
- { 103, "TestUser103" }
- });
-
- migrationBuilder.CreateIndex(
- name: "IX_TestUserChanges_Id",
- table: "TestUserChanges",
- column: "Id");
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropChangeTrigger(
- triggerName: "TestUsers_ChangeTrigger");
-
- migrationBuilder.DropTable(
- name: "TestUserChanges");
-
- migrationBuilder.DropTable(
- name: "TestUsers");
- }
- }
-}
diff --git a/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/add-migration.ps1 b/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/add-migration.ps1
index ccb989d..f910f6d 100644
--- a/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/add-migration.ps1
+++ b/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/add-migration.ps1
@@ -9,11 +9,11 @@ $noBuildArgument = if ($Global:NoBuild) { "--no-build" } else { "" }
if (Test-Path $OutputDir)
{
- Write-Output "Removing existing migrations..."
+ Write-Host "Removing existing migrations..."
Remove-Item -Recurse -Force -Path $OutputDir
}
-Write-Output "Scaffolding new migration for $Context..."
+Write-Host "Scaffolding new migration for $Context..."
dotnet ef migrations add Initial `
--context $Context `
--output-dir $OutputDir `
diff --git a/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/readd-all-migrations.ps1 b/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/readd-all-migrations.ps1
index cc4cd3b..6cb2564 100644
--- a/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/readd-all-migrations.ps1
+++ b/tests/EFCore.ChangeTriggers.SqlServer.Tests.Integration/readd-all-migrations.ps1
@@ -1,19 +1,17 @@
$global:NoBuild = $false
-$persistenceDirs = Get-ChildItem -Recurse -Directory | Where-Object { $_.FullName -like "$PSScriptRoot\*Persistence" }
-
-Write-Output $PSScriptRoot
+$persistenceDirs = Get-ChildItem -Recurse -Directory | Where-Object { $_.FullName -like (Join-Path $PSScriptRoot "*Persistence") }
Write-Host "Found $($persistenceDirs.Count) directories to process..."
-# Delete current migrations before rebuild
+# Delete current migrations
foreach ($persistenceDir in $persistenceDirs) {
$migrationsPath = Join-Path $persistenceDir.FullName "Migrations"
if (Test-Path $migrationsPath) {
- Write-Output "Deleting Migrations folder: $migrationsPath"
+ Write-Host "Deleting Migrations folder: $migrationsPath"
Remove-Item -Recurse -Force -Path $migrationsPath
} else {
- Write-Output "Migrations folder not found in: $($persistenceDir.FullName)"
+ Write-Host "Migrations folder not found in: $($persistenceDir.FullName)"
}
}
@@ -22,12 +20,12 @@ foreach ($persistenceDir in $persistenceDirs) {
$addMigrationScript = Join-Path $persistenceDir.FullName "add-migration.ps1"
if (Test-Path $addMigrationScript) {
- Write-Output "Running add-migration.ps1 in: $($persistenceDir.FullName)"
+ Write-Host "Running add-migration.ps1 in: $($persistenceDir.FullName)"
$noBuildArgument = if ($loopCounter > 0) { "-NoBuild" } else { "" }
& $addMigrationScript $noBuildArgument
} else {
- Write-Output "add-migration.ps1 not found in: $($persistenceDir.FullName)"
+ Write-Host "add-migration.ps1 not found in: $($persistenceDir.FullName)"
}
# Only build once