Store Types not documented.
The MigrationBuilder.InsertData() method accepts a string[] columnTypes with no description of what the text of the strings must be. The format must be something specific as "String" "System.String" "System.Data.SqlTypes.SqlString" "nvarchar" and "nvarchar(max)" all throw errors...
@StuartSpencer-CSIRO Data in migrations usually comes from the model, rather than calling these APIs directly. See Data seeding for more information.
@StuartSpencer-CSIRO As it says in the documentation it's a "A list of store types for the columns into which data will be inserted.", so something like ["bigint", "nvarchar(max)"] for SQL Server
Share the full call and the exceptions you get.
Have you tried those values @AndriySvyryd? because they did not work for me. The values I found to work was the name (without the namespace) of the SQL Data type. E.g. "SqlString","SqlInt16","SqlBoolean"... I think you may have just proved my point about the doco needing work.
System.InvalidOperationException: The store type 'int' used for the column 'codes.LAND_USES.lu_level' in a migration data operation is not supported by the current provider.
From: Andriy Svyryd @.> Sent: Friday, 6 September 2024 3:40 AM To: dotnet/efcore @.> Cc: Spencer, Stuart (A&F, Black Mountain) @.>; Mention @.> Subject: Re: [dotnet/efcore] Store Types not documented. (Issue #34549)
@StuartSpencer-CSIROhttps://github.com/StuartSpencer-CSIRO As it says in the documentationhttps://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.migrations.migrationbuilder.insertdata?view=efcore-8.0#microsoft-entityframeworkcore-migrations-migrationbuilder-insertdata(system-string-system-string()-system-string()-system-object(-)-system-string) it's a "A list of store types for the columns into which data will be inserted.", so something like ["bigint", "nvarchar(max)"] for SQL Server
Share the full call and the exceptions you get.
— Reply to this email directly, view it on GitHubhttps://github.com/dotnet/efcore/issues/34549#issuecomment-2332299720, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A6KDTILNKUI42WMRIY4BGCDZVCJP5AVCNFSM6AAAAABNHESVQWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZSGI4TSNZSGA. You are receiving this because you were mentioned.Message ID: @.***>
I am not able to repro this, and we have tests for this like https://github.com/dotnet/efcore/blob/af1047eeae730a37dd0d106c113e3b518132adbc/test/EFCore.Relational.Specification.Tests/Migrations/MigrationsSqlGeneratorTestBase.cs#L219
Please share a minimal runnable project that exhibits this issue.
I don’t know your code at all, and that level is well beyond me. I would however suspect that if you actually run against a physical database, in the order that they are specified, you may see that renaming the “people” table to “person” in the middle would break the rest of the test execution. Also, it is when the actual insert statements are being constructed, not when the migrationBuilder is being added to (i.e. the migrationBuilder.InsertData statement is called) that the exception occurs. All of the SQL is built only as the migrationBuilder seems to fall out of context, i.e. at the end of the migration. Again, I’m not smart enough to know how that impacts your tests. If you confirm that you end up with a physical SQL Server database with data in it, named either “people” or “person”, then I have a small hat here ready to be eaten.
From: Andriy Svyryd @.> Sent: Friday, 6 September 2024 9:26 AM To: dotnet/efcore @.> Cc: Spencer, Stuart (A&F, Black Mountain) @.>; Mention @.> Subject: Re: [dotnet/efcore] Store Types not documented. (Issue #34549)
I am not able to repro this, and we have tests for this like https://github.com/dotnet/efcore/blob/af1047eeae730a37dd0d106c113e3b518132adbc/test/EFCore.Relational.Specification.Tests/Migrations/MigrationsSqlGeneratorTestBase.cs#L219
Please share a minimal runnable project that exhibits this issue.
— Reply to this email directly, view it on GitHubhttps://github.com/dotnet/efcore/issues/34549#issuecomment-2332877633, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A6KDTILJAL4626JN2B4RTZDZVDSALAVCNFSM6AAAAABNHESVQWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZSHA3TONRTGM. You are receiving this because you were mentioned.Message ID: @.***>
Those tests execute code beyond the point where the exception you see would be thrown.
Again, please share a minimal runnable project that exhibits this issue if you want us to investigate this further.