Wednesday, January 29, 2014

Improving bulk insert performance in Entity framework

Sometimes Entity Framework will have poor performance when inserting records. A possible workaround is to set the following flags:
yourContext.Configuration.AutoDetectChangesEnabled = false;
yourContext.Configuration.ValidateOnSaveEnabled = false;
This should be done before the calls to 'AddObject'.   In my case, this reduced the time a piece of code took to process 2,000 records from 8 minutes down to about 10 seconds.

This fix requires more research to determine if there are side-effects to setting these.  If this is a shared context, then the flags should be set back to their original values after 'SaveChanges' has been called.

Note that this only works with DBContext,and not ObjectContext

Monday, January 6, 2014

Moving a Repository from SVN to Git on VisualStudio.com


  1. Create a new folder.
  2. Launch a Git Bash prompt and navigate to this folder.
  3. Use git to clone the SVN repository to this folder. 
    1. git svn clone http://svn/repo/here/trunk   (Taken from http://stackoverflow.com/a/79178/224531)
    2. This may take a while if there is a lot of history.  But the end result is a stand-alone Git repo with all the history in it. 
  4. Go the TFS site (visualstudio.com), and create a new project using Git as the source control. 
  5. After this is created open the project and click on the 'Code' menu.
  6. It should show that the repository is empty.  Follow the steps on this page, using the Bash command prompt, to attach the local repo to this new origin, and push the changes to the TFS site. 

Friday, January 3, 2014

Fixing 500 Errors with IISExpress

When an app throws 500 errors in IIS Express with no additional debugging information, try the following:
  • Close VS Studio - solution set with IISExpress
  • Go to: /Document/IISExpress/config/ in your profile
  • Rename or delete applicationhost.config
  • Open your solution in VS Studio
  • A dialog may fire up from IISExpress - this will set a fresh config.
  • try to run your web app.