We want to modify a table in our database by adding a column and then updating all of the records in that table. For simplification, we are adding ValueB as the new column:
ID | ValueA | ValueB (new column) |
---|---|---|
1 | 0583 | 100 |
2 | 0381 | 200 |
- Step 1: Add the new column (straight forward in EF)
- Step 2: Get the rows
- Step 3: Using
ValueA
feed it into some blackbox C# method which returns a newValueA
and an additionalValueB
. - Step 4: Update the rows with the new
ValueA
andValueB
.
I am not sure simply using the Sql
method will suffice, and there isn’t really a way to avoid using the C# method. We literally have to update the records by feeding the original ValueA
into the method to get the new ValueA
and ValueB
.
2