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.
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.
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.