Skip to content

Commit

Permalink
Enable primitive collections and refactor MySQL EF options.
Browse files Browse the repository at this point in the history
Added support for primitive collections and parameterized collection translation in MySQL EF configurations. Removed redundant `EnablePrimitiveCollectionsSupport` calls in program configuration to centralize the behavior.
  • Loading branch information
sfmskywalker committed Dec 28, 2024
1 parent 021795f commit 4ed58c6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/apps/Elsa.Server.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@
else if (sqlDatabaseProvider == SqlDatabaseProvider.PostgreSql)
ef.UsePostgreSql(postgresConnectionString!);
#if !NET9_0
else if (sqlDatabaseProvider == SqlDatabaseProvider.MySql)
ef.UseMySql(mySqlConnectionString, null, opt => opt.EnablePrimitiveCollectionsSupport());
else if (sqlDatabaseProvider == SqlDatabaseProvider.MySql)
ef.UseMySql(mySqlConnectionString);
#endif
else if (sqlDatabaseProvider == SqlDatabaseProvider.CockroachDb)
ef.UsePostgreSql(cockroachDbConnectionString!);
Expand Down Expand Up @@ -187,7 +187,7 @@
ef.UsePostgreSql(postgresConnectionString!);
#if !NET9_0
else if (sqlDatabaseProvider == SqlDatabaseProvider.MySql)
ef.UseMySql(mySqlConnectionString, null, opt => opt.EnablePrimitiveCollectionsSupport());
ef.UseMySql(mySqlConnectionString);
#endif
else if (sqlDatabaseProvider == SqlDatabaseProvider.CockroachDb)
ef.UsePostgreSql(cockroachDbConnectionString!);
Expand Down Expand Up @@ -233,7 +233,7 @@
ef.UsePostgreSql(postgresConnectionString!);
#if !NET9_0
else if (sqlDatabaseProvider == SqlDatabaseProvider.MySql)
ef.UseMySql(mySqlConnectionString, null, opt => opt.EnablePrimitiveCollectionsSupport());
ef.UseMySql(mySqlConnectionString);
#endif
else if (sqlDatabaseProvider == SqlDatabaseProvider.CockroachDb)
ef.UsePostgreSql(cockroachDbConnectionString!);
Expand Down Expand Up @@ -361,7 +361,7 @@
ef.UsePostgreSql(postgresConnectionString);
#if !NET9_0
else if (sqlDatabaseProvider == SqlDatabaseProvider.MySql)
ef.UseMySql(mySqlConnectionString, null, opt => opt.EnablePrimitiveCollectionsSupport());
ef.UseMySql(mySqlConnectionString);
#endif
else if (sqlDatabaseProvider == SqlDatabaseProvider.CockroachDb)
ef.UsePostgreSql(cockroachDbConnectionString!);
Expand Down Expand Up @@ -550,7 +550,7 @@
if (sqlDatabaseProvider == SqlDatabaseProvider.PostgreSql) ef.UsePostgreSql(postgresConnectionString);
#if !NET9_0
if (sqlDatabaseProvider == SqlDatabaseProvider.MySql)
ef.UseMySql(mySqlConnectionString, null, opt => opt.EnablePrimitiveCollectionsSupport());
ef.UseMySql(mySqlConnectionString);
#endif
if (sqlDatabaseProvider == SqlDatabaseProvider.CockroachDb) ef.UsePostgreSql(cockroachDbConnectionString);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public static DbContextOptionsBuilder UseElsaMySql(this DbContextOptionsBuilder
db
.MigrationsAssembly(options.GetMigrationsAssemblyName(migrationsAssembly))
.MigrationsHistoryTable(options.GetMigrationsHistoryTableName(), options.GetSchemaName())
.SchemaBehavior(MySqlSchemaBehavior.Ignore);
.SchemaBehavior(MySqlSchemaBehavior.Ignore)
.EnablePrimitiveCollectionsSupport()
.TranslateParameterizedCollectionsToConstants();

configure?.Invoke(db);
});
Expand Down

0 comments on commit 4ed58c6

Please sign in to comment.