Friday, April 18, 2014

How to disable generating .PDB files while compiling .NET assembly/ website in Release mode

While compiling your .NET assembly or publishing ASP.NET or MVC project in Release mode, you may observe .pdb file also gets generated along with necessary .dll or supporting files.
PDB file contains debugging information and symbol which does not make any sense during deployment or release of a product.
In order to get rid of generating PDB files during publish/ build -
1. Open the project properties of a project in Visual Studio
2. Click on "Build" tab
3. Make sure the configuration selected is "Release"
4. Click on "Advanced" button
5. Select "none" in "Debug Info" selection box.
6. Click OK, and save the project
Try building the project, and you will not see PDB files.

Screenshots:



Tuesday, April 1, 2014

Function Evaluation Timed out error in Entity Framework

While running a time-consuming queries in Entity Framework, you may face the error saying "Function evaluation timed out".
In order to fix this error, you will need to increase the timeout of underlying DbContext.

Steps


  • Open "EntityName.Context.cs" file.
  • This file must be having an Entity class inherited from "DbContext"
  • Copy following code in the default constructor of this class:
            var adapter = (IObjectContextAdapter)this;
            var objectContext = adapter.ObjectContext;
            objectContext.CommandTimeout = 120; //2 minutes

Please note that CommandTimeout is in seconds.