Add support for type mapping in EF Core 10 (MySQL Connector/NET)Add support for string[] type mapping in EF Core 10 #81
+47
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces support for string[] type mapping in the MySQL EF Core provider.
Problem
When using EF Core 10 with MySQL, queries that rely on Contains with a string[] fail with the following exception:
``InvalidOperationException: Expression '@stringarray' in the SQL tree does not have a type mapping assigned.'`
This occurs because the provider does not currently assign a relational type mapping for string collections, even though EF Core 10 expects it.
Solution
The type mapping source has been updated to handle both string and string[]:
This ensures that string[] is recognized and mapped correctly, allowing queries such as:
string[] stringArray = new string[] { "TEST" }; var result = context.StringCodeMatch.FirstOrDefault(q => stringArray.Contains(q.Code));to execute without error.