Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

With appreciation for the answers and sound advice provided here, I have concluded that the real source of the issue was not my improper use of try/catch nor FirstOrDefault() or any of that, but rather, it was the Excel package.

To fix this, the only solution would be to convert the Excel into a CSV which would allow for faster access of data. Instead of that, I just chose to modify my DataRowStart and DataRowFinish by shrinking the window so it wouldn't get bogged down.

Update:

After converting my document to CSV and using FileHelpers and changing the runtime configuration changing the runtime configuration of my DbContext like so:

yourContext.Configuration.AutoDetectChangesEnabled = false;
yourContext.Configuration.ValidateOnSaveEnabled = false;

... I was able to validate and insert all 40k records in under 15 minutes; whereas, before it would've taken hours (if it finished at all). I think most of the benefit actually came from the DbContext change. That alone was a major improvement.

With appreciation for the answers and sound advice provided here, I have concluded that the real source of the issue was not my improper use of try/catch nor FirstOrDefault() or any of that, but rather, it was the Excel package.

To fix this, the only solution would be to convert the Excel into a CSV which would allow for faster access of data. Instead of that, I just chose to modify my DataRowStart and DataRowFinish by shrinking the window so it wouldn't get bogged down.

Update:

After converting my document to CSV and using FileHelpers and changing the runtime configuration of my DbContext like so:

yourContext.Configuration.AutoDetectChangesEnabled = false;
yourContext.Configuration.ValidateOnSaveEnabled = false;

... I was able to validate and insert all 40k records in under 15 minutes; whereas, before it would've taken hours (if it finished at all). I think most of the benefit actually came from the DbContext change. That alone was a major improvement.

With appreciation for the answers and sound advice provided here, I have concluded that the real source of the issue was not my improper use of try/catch nor FirstOrDefault() or any of that, but rather, it was the Excel package.

To fix this, the only solution would be to convert the Excel into a CSV which would allow for faster access of data. Instead of that, I just chose to modify my DataRowStart and DataRowFinish by shrinking the window so it wouldn't get bogged down.

Update:

After converting my document to CSV and using FileHelpers and changing the runtime configuration of my DbContext like so:

yourContext.Configuration.AutoDetectChangesEnabled = false;
yourContext.Configuration.ValidateOnSaveEnabled = false;

... I was able to validate and insert all 40k records in under 15 minutes; whereas, before it would've taken hours (if it finished at all). I think most of the benefit actually came from the DbContext change. That alone was a major improvement.

added 615 characters in body
Source Link
user1477388
  • 325
  • 3
  • 12

With appreciation for the answers and sound advice provided here, I have concluded that the real source of the issue was not my improper use of try/catch nor FirstOrDefault() or any of that, but rather, it was the Excel package.

To fix this, the only solution would be to convert the Excel into a CSV which would allow for faster access of data. Instead of that, I just chose to modify my DataRowStart and DataRowFinish by shrinking the window so it wouldn't get bogged down.

Update:

After converting my document to CSV and using FileHelpers and changing the runtime configuration of my DbContext like so:

yourContext.Configuration.AutoDetectChangesEnabled = false;
yourContext.Configuration.ValidateOnSaveEnabled = false;

... I was able to validate and insert all 40k records in under 15 minutes; whereas, before it would've taken hours (if it finished at all). I think most of the benefit actually came from the DbContext change. That alone was a major improvement.

With appreciation for the answers and sound advice provided here, I have concluded that the real source of the issue was not my improper use of try/catch nor FirstOrDefault() or any of that, but rather, it was the Excel package.

To fix this, the only solution would be to convert the Excel into a CSV which would allow for faster access of data. Instead of that, I just chose to modify my DataRowStart and DataRowFinish by shrinking the window so it wouldn't get bogged down.

With appreciation for the answers and sound advice provided here, I have concluded that the real source of the issue was not my improper use of try/catch nor FirstOrDefault() or any of that, but rather, it was the Excel package.

To fix this, the only solution would be to convert the Excel into a CSV which would allow for faster access of data. Instead of that, I just chose to modify my DataRowStart and DataRowFinish by shrinking the window so it wouldn't get bogged down.

Update:

After converting my document to CSV and using FileHelpers and changing the runtime configuration of my DbContext like so:

yourContext.Configuration.AutoDetectChangesEnabled = false;
yourContext.Configuration.ValidateOnSaveEnabled = false;

... I was able to validate and insert all 40k records in under 15 minutes; whereas, before it would've taken hours (if it finished at all). I think most of the benefit actually came from the DbContext change. That alone was a major improvement.

Source Link
user1477388
  • 325
  • 3
  • 12

With appreciation for the answers and sound advice provided here, I have concluded that the real source of the issue was not my improper use of try/catch nor FirstOrDefault() or any of that, but rather, it was the Excel package.

To fix this, the only solution would be to convert the Excel into a CSV which would allow for faster access of data. Instead of that, I just chose to modify my DataRowStart and DataRowFinish by shrinking the window so it wouldn't get bogged down.

lang-cs

AltStyle によって変換されたページ (->オリジナル) /