You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is nothing that can help to manipulate with data with migrations:
basically it can be implemented like migrationBuilder.Sql("Insert ...");
but would be grate to implement it like: migrationBuilder.Insert.IntoTable("Users").Row(new { FirstName = "John", LastName = "Smith" });
there is a case why really need it this way:
there is a table Posts with string content column, but if I want a table Contents, so i want to add a table, select data, insert data and then delete column
@bricelam in triage we discusses that this was probably a dupe of an existing issue to support data motion functionality. Can you please help me find that issue? 😄
Note from triage: Migrations code cannot reference application types since changes in those types will break existing migrations. This means there is little value in any API here over just writing SQL directly using migrationBuilder.Sql("...").
Note from triage: Migrations code cannot reference application types since changes in those types will break existing migrations. This means there is little value in any API here over just writing SQL directly using migrationBuilder.Sql("...").
I think it still adds quite some value.
E.g.
If you write migrations for different DBs you need to make subtle syntax changes.
Activity
divega commentedon Jun 7, 2016
@bricelam in triage we discusses that this was probably a dupe of an existing issue to support data motion functionality. Can you please help me find that issue? 😄
bricelam commentedon Jun 7, 2016
Well, there's Work Item 16 on EF6 😏 Looks like it never made it to our EF Core backlog. We'll use this issue.
[-]Initialize data via migrations[/-][+]Migrations: Data motion APIs[/+]bricelam commentedon Jun 7, 2016
In addition to inserting, updating, and deleting data. This issue also covers transferring or moving data between tables and columns.
grahamehorner commentedon Oct 31, 2017
please consider sharding/partitioning data
bricelam commentedon Apr 25, 2018
Note, in version 2.0.0, we added
InsertData(),UpdateData(), andDeleteData()migration operations.ajcvickers commentedon Oct 26, 2022
Note from triage: Migrations code cannot reference application types since changes in those types will break existing migrations. This means there is little value in any API here over just writing SQL directly using
migrationBuilder.Sql("...").pmoleri commentedon Jul 28, 2025
I think it still adds quite some value.
E.g.
migrationBuilder.Sql("...")will generate a valid script only while the table columns still exist, otherwise the script will fail to parse and you need to wrap your SQL in a anexec("")and escape strings inside. See: migrationBuilder.InsertData generates SQL with 'Invalid column name' in idempotent scripts #17826So, it helps with the correctness of the migration scripts and portability to different DBs.