Enable MySQL primitive collections support and update configs

Add support for EF Core primitive collections in MySQL by specifying `EnablePrimitiveCollectionsSupport()` in the DbContext configuration. Updated the Docker Compose file to rename the MySQL volume and adjusted appsettings.json to include a MySQL connection string and set MySQL as the default database provider.
This commit is contained in:
Sipke Schoorstra 2024-12-28 18:56:29 +01:00
parent 470399ed21
commit 021795f53a
3 changed files with 10 additions and 8 deletions

View file

@ -23,7 +23,7 @@
ports:
- "3306:3306"
volumes:
- mysql_data:/var/lib/mysql
- mysql_data1:/var/lib/mysql
mongodb:
image: mongo:latest
@ -104,6 +104,6 @@
volumes:
postgres-data:
mysql_data:
mysql_data1:
cockroachdb-data:
mongodb_data:

View file

@ -151,7 +151,7 @@ services
ef.UsePostgreSql(postgresConnectionString!);
#if !NET9_0
else if (sqlDatabaseProvider == SqlDatabaseProvider.MySql)
ef.UseMySql(mySqlConnectionString);
ef.UseMySql(mySqlConnectionString, null, opt => opt.EnablePrimitiveCollectionsSupport());
#endif
else if (sqlDatabaseProvider == SqlDatabaseProvider.CockroachDb)
ef.UsePostgreSql(cockroachDbConnectionString!);
@ -187,7 +187,7 @@ services
ef.UsePostgreSql(postgresConnectionString!);
#if !NET9_0
else if (sqlDatabaseProvider == SqlDatabaseProvider.MySql)
ef.UseMySql(mySqlConnectionString);
ef.UseMySql(mySqlConnectionString, null, opt => opt.EnablePrimitiveCollectionsSupport());
#endif
else if (sqlDatabaseProvider == SqlDatabaseProvider.CockroachDb)
ef.UsePostgreSql(cockroachDbConnectionString!);
@ -233,7 +233,7 @@ services
ef.UsePostgreSql(postgresConnectionString!);
#if !NET9_0
else if (sqlDatabaseProvider == SqlDatabaseProvider.MySql)
ef.UseMySql(mySqlConnectionString);
ef.UseMySql(mySqlConnectionString, null, opt => opt.EnablePrimitiveCollectionsSupport());
#endif
else if (sqlDatabaseProvider == SqlDatabaseProvider.CockroachDb)
ef.UsePostgreSql(cockroachDbConnectionString!);
@ -361,7 +361,7 @@ services
ef.UsePostgreSql(postgresConnectionString);
#if !NET9_0
else if (sqlDatabaseProvider == SqlDatabaseProvider.MySql)
ef.UseMySql(mySqlConnectionString);
ef.UseMySql(mySqlConnectionString, null, opt => opt.EnablePrimitiveCollectionsSupport());
#endif
else if (sqlDatabaseProvider == SqlDatabaseProvider.CockroachDb)
ef.UsePostgreSql(cockroachDbConnectionString!);
@ -549,7 +549,8 @@ services
if (sqlDatabaseProvider == SqlDatabaseProvider.SqlServer) ef.UseSqlServer(sqlServerConnectionString);
if (sqlDatabaseProvider == SqlDatabaseProvider.PostgreSql) ef.UsePostgreSql(postgresConnectionString);
#if !NET9_0
if (sqlDatabaseProvider == SqlDatabaseProvider.MySql) ef.UseMySql(mySqlConnectionString);
if (sqlDatabaseProvider == SqlDatabaseProvider.MySql)
ef.UseMySql(mySqlConnectionString, null, opt => opt.EnablePrimitiveCollectionsSupport());
#endif
if (sqlDatabaseProvider == SqlDatabaseProvider.CockroachDb) ef.UsePostgreSql(cockroachDbConnectionString);
});

View file

@ -18,6 +18,7 @@
"AllowedHosts": "*",
"ConnectionStrings": {
"Sqlite": "Data Source=App_Data/elsa.sqlite.db;Cache=Shared;",
"MySql": "Server=localhost;Database=elsa;Uid=admin;Pwd=password;",
"PostgreSql": "Server=localhost;Username=elsa;Database=elsa;Port=5432;Password=elsa;SSLMode=Prefer;MaxPoolSize=2000;Timeout=60",
"CockroachDb": "Host=localhost;Port=26257;Database=elsa;SslMode=Disable;Username=root;IncludeErrorDetail=true",
"MongoDb": "mongodb://localhost:27017/elsa-workflows",
@ -25,7 +26,7 @@
"RabbitMq": "amqp://guest:guest@localhost:5672",
"Redis": "localhost:6379,abortConnect=false"
},
"DatabaseProvider": "Sqlite",
"DatabaseProvider": "MySql",
"Multitenancy": {
"Tenants": [
{