C
C#2w ago
Levvy

Anyone tried C# 10 with Aspire 13 + EF 13 + MySQL?

Steps to reproduce: - Create Aspire Startup solution, add Aspire.Hosting.MySql to Aspire project with var mysql = builder.AddMySql("mysql") .WithLifetime(ContainerLifetime.Persistent); var mysqldb = mysql.AddDatabase("mysqldb"); Then add Aspire.Pomelo.EntityFrameworkCore.MySql (version 13) with code builder.AddMySqlDbContext<ExampleDbContext>(connectionName: "mysqldb"); to API project. At this point we have Entity Framework Pomelo version mismatch as EF somehow requests 8.0.3 version. Not even any 9 version, but 8. Right now do not even know where to write the bug ticket as I don't know to which components fault it is.
10 Replies
davidfowl
davidfowl2w ago
What is the error?
Levvy
LevvyOP2w ago
When using Pomelo.EntityFrameworkCore.MySql 9.0.0 which is still not on 10/13 version I get on code like:
services.AddPooledDbContextFactory<IdentityDbContext>(options =>
options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString), mysqlOptions =>
{
mysqlOptions.EnableRetryOnFailure(maxRetryCount: 3, maxRetryDelay: TimeSpan.FromSeconds(10), null);
}),
poolSize: 128);

System.MissingMethodException: 'Method not found: 'System.String Microsoft.EntityFrameworkCore.Diagnostics.AbstractionsStrings.ArgumentIsEmpty(System.Object)'.'
stacktrace in message.txt
services.AddPooledDbContextFactory<IdentityDbContext>(options =>
options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString), mysqlOptions =>
{
mysqlOptions.EnableRetryOnFailure(maxRetryCount: 3, maxRetryDelay: TimeSpan.FromSeconds(10), null);
}),
poolSize: 128);

System.MissingMethodException: 'Method not found: 'System.String Microsoft.EntityFrameworkCore.Diagnostics.AbstractionsStrings.ArgumentIsEmpty(System.Object)'.'
stacktrace in message.txt
Hovewer when I try to use Aspire.Pomelo.EntityFrameworkCore.MySql 13.0.0: warning NU1608: Detected package version outside of dependency constraint: Pomelo.EntityFrameworkCore.MySql 8.0.3 requires Microsoft.EntityFrameworkCore.Relational (>= 8.0.13 && <= 8.0.999) but version Microsoft.EntityFrameworkCore.Relational 10.0.0 was resolved.
davidfowl
davidfowl2w ago
Definitely file an issue
Levvy
LevvyOP2w ago
To which repo?
davidfowl
davidfowl2w ago
dotnet/aspire
Levvy
LevvyOP2w ago
Will do that tomorrow 👍 thanks
Pobiega
Pobiega2w ago
I'd also urge you to reconsider MySQL in general. It is not a good database. $whynotmysql
MODiX
MODiX2w ago
https://dev.mysql.com/doc/refman/8.0/en/insert.html
Inserting NULL into a column that has been declared NOT NULL. For multiple-row INSERT statements or INSERT INTO ... SELECT statements, the column is set to the implicit default value for the column data type. This is 0 for numeric types, the empty string ('') for string types, and the “zero” value for date and time types. INSERT INTO ... SELECT statements are handled the same way as multiple-row inserts because the server does not examine the result set from the SELECT to see whether it returns a single row. (For a single-row INSERT, no warning occurs when NULL is inserted into a NOT NULL column. Instead, the statement fails with an error.) Setting a numeric column to a value that lies outside the column range. The value is clipped to the closest endpoint of the range. Assigning a value such as '10.34 a' to a numeric column. The trailing nonnumeric text is stripped off and the remaining numeric part is inserted. If the string value has no leading numeric part, the column is set to 0. Inserting a string into a string column (CHAR, VARCHAR, TEXT, or BLOB) that exceeds the column maximum length. The value is truncated to the column maximum length. Inserting a value into a date or time column that is illegal for the data type. The column is set to the appropriate zero value for the type. https://mariadb.com/kb/en/start-transaction/#ddl-statements DDL statements cannot be run in transactions; they will automatically commit the in-progress transaction and start a new one. Reversing a schema change requires explicitly doing so, or restoring from backup.
Angius
Angius2w ago
Jaysus, that's a tag and a half lmao
Levvy
LevvyOP2w ago
That's why EF has to be correctly set witch correct annotation. For a database that would have around 20x more writes(updates) than reads and some relations this is better to use at a records count max 10000.

Did you find this page helpful?