Skip to content

Commit 216a1e3

Browse files
Copilotdanielgerlag
andcommitted
Implement dynamic ProductVersion based on target framework using preprocessor directives
Co-authored-by: danielgerlag <[email protected]>
1 parent 82932f7 commit 216a1e3

File tree

5 files changed

+35
-14
lines changed

5 files changed

+35
-14
lines changed

src/providers/WorkflowCore.Persistence.EntityFramework/Services/WorkflowDbContext.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,6 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
5656
{
5757
base.OnConfiguring(optionsBuilder);
5858
optionsBuilder.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
59-
60-
// Configure warning handling for PendingModelChangesWarning
61-
// This warning can be triggered by:
62-
// 1. ProductVersion mismatch (false positive when using EF Core 9.x with older snapshots)
63-
// 2. Legitimate model changes that need migrations
64-
//
65-
// We convert the warning to a log message so developers can still see it in logs
66-
// but it won't throw an exception that prevents application startup
67-
optionsBuilder.ConfigureWarnings(warnings =>
68-
warnings.Log(Microsoft.EntityFrameworkCore.Diagnostics.RelationalEventId.PendingModelChangesWarning));
6959
}
7060
}
7161
}

src/providers/WorkflowCore.Persistence.MySQL/Migrations/MysqlPersistenceProviderModelSnapshot.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,16 @@ protected override void BuildModel(ModelBuilder modelBuilder)
1515
#pragma warning disable 612, 618
1616
modelBuilder
1717
.HasAnnotation("Relational:MaxIdentifierLength", 64)
18-
.HasAnnotation("ProductVersion", "5.0.8");
18+
#if NETSTANDARD2_1
19+
.HasAnnotation("ProductVersion", "5.0.1")
20+
#elif NET6_0
21+
.HasAnnotation("ProductVersion", "7.0.0")
22+
#elif NET8_0
23+
.HasAnnotation("ProductVersion", "9.0.9")
24+
#else
25+
.HasAnnotation("ProductVersion", "9.0.9")
26+
#endif
27+
;
1928

2029
modelBuilder.Entity("WorkflowCore.Persistence.EntityFramework.Models.PersistedEvent", b =>
2130
{

src/providers/WorkflowCore.Persistence.Oracle/Migrations/OracleContextModelSnapshot.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ protected override void BuildModel(ModelBuilder modelBuilder)
1717
{
1818
#pragma warning disable 612, 618
1919
modelBuilder
20-
.HasAnnotation("ProductVersion", "6.0.3")
20+
#if NET6_0
21+
.HasAnnotation("ProductVersion", "7.0.0")
22+
#elif NET8_0
23+
.HasAnnotation("ProductVersion", "9.0.9")
24+
#else
25+
.HasAnnotation("ProductVersion", "9.0.9")
26+
#endif
2127
.HasAnnotation("Relational:MaxIdentifierLength", 128);
2228

2329
OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);

src/providers/WorkflowCore.Persistence.PostgreSQL/Migrations/PostgresPersistenceProviderModelSnapshot.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ protected override void BuildModel(ModelBuilder modelBuilder)
1717
{
1818
#pragma warning disable 612, 618
1919
modelBuilder
20-
.HasAnnotation("ProductVersion", "8.0.19")
20+
#if NETSTANDARD2_1
21+
.HasAnnotation("ProductVersion", "5.0.1")
22+
#elif NET6_0
23+
.HasAnnotation("ProductVersion", "7.0.0")
24+
#elif NET8_0
25+
.HasAnnotation("ProductVersion", "9.0.9")
26+
#else
27+
.HasAnnotation("ProductVersion", "9.0.9")
28+
#endif
2129
.HasAnnotation("Relational:MaxIdentifierLength", 63);
2230

2331
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);

src/providers/WorkflowCore.Persistence.SqlServer/Migrations/SqlServerPersistenceProviderModelSnapshot.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ protected override void BuildModel(ModelBuilder modelBuilder)
1616
#pragma warning disable 612, 618
1717
modelBuilder
1818
.HasAnnotation("Relational:MaxIdentifierLength", 128)
19-
.HasAnnotation("ProductVersion", "5.0.8")
19+
#if NETSTANDARD2_1
20+
.HasAnnotation("ProductVersion", "5.0.1")
21+
#elif NET6_0
22+
.HasAnnotation("ProductVersion", "7.0.0")
23+
#elif NET8_0 || NET9_0
24+
.HasAnnotation("ProductVersion", "9.0.9")
25+
#else
26+
.HasAnnotation("ProductVersion", "9.0.9")
27+
#endif
2028
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
2129

2230
modelBuilder.Entity("WorkflowCore.Persistence.EntityFramework.Models.PersistedEvent", b =>

0 commit comments

Comments
 (0)