c# - Updating large amounts of data in an EF Migration -


I have a SQL table in which there are hundred million lines or in it, and its schema is managed by EF migration.

I want to change the values ​​in the enim connected to that table, so I will have to update all the values ​​in the DB into the new values. Something like the bottom

  this.SQL ("MyTable set MyEnum = 0 where MyEnum = -1");  

It would be nice to have a small table, but this is not true due to the size of the table to run such a big update at a time (I have connection timeout, tempi Meet the issue of space, transfer log space issues ect). It would be much better to do this in batches example:

  while (ctx.MyTable.Any (m => m.MyEnum == -1) {this.SQL (" UPDATE TOP (100000000) MyTable SET MyEnum = 0 WHERE MyEnum = -1 "); }  

Unfortunately, I can prepare a way to read from the table during a migration (for example, you use migration ctx.MyTable.Any (m => M .MyEnum == -1) ). There is a way to do this so that I can batch in my EF Migration update.

My recommendation, depending on how slow the EF is for you (also when in batches Is doing it), you have to actually do this to create a stored procedure, and then just ask the migration to be stored just when the process is running, hopefully it should run faster because everything Will be done on SQL sides.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -