I am running CSV import into SQL db through an ASP.NET MVC application.
I repeat all the lines in the CSV, creating an equivalent object for each and adding each to the current context.
If there is at least one row to add, I want to delete all existing rows from the recordable table, and then commit the new objects.
My question is: is it safe to call ExecuteSqlCommandAsyncand not wait for the result before I then call await db.SaveChangesAsync();as follows:
db.Database.ExecuteSqlCommandAsync("delete from tblName");
await db.SaveChangesAsync();
Or should I awaitdelete a call before I make a change change call? In this case, can I also make calls for non-synchronous versions?
Currently, I do not expect this, and everything works as expected locally (almost without delay), that is, existing data is deleted and new data is added. It bothers me if there is anything else that I should consider when deploying the solution, and the web server and SQL server do not have to be in the same field.
source
share