Thursday, October 29, 2015

SQL Server: Save changes is not permitted. Resolution

Save changes is not permitted. The changes you have made require the following tables to be dropped and recreated. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created.

User canceled out of save dialog.

Solution:

  • Go to Tools > Options

  • Go to Designers > Table and Database Designers
  • Uncheck the Prevent saving changes that require the table recreation.

Tuesday, October 20, 2015

Difference between Eager Loading, Lazy Loading & Explicit Loading

Eagerly Loading

This is the process to load all the related entities while loading an entity. When we load an entity, we will be loading all the related entities all together. We use Include method to achieve Eager Loading. For example following will load all the Categories + All the Products of those categories:

using (InventoryContext ctx = new InventoryContext())
{
    var cats = ctx.Categories.Include(b => b.Products).ToList();
}

We can load related entities up to n number of levels.

Lazy Loading

Lazy loading is a concept where we delay the loading of the object until the point at which it is needed. Means lazy loading does not allow to load objects unnecessarily objects will be loaded only when they are needed.

Lazy loading created problem with serialization. Serializers access each and every property to serialize. Hence all the related entities will load. This will increase the overhead and will result in a large result set. So it is advised to turn Lazy loading OFF when work with Serialization.

Explicitly Loading

This is the process to load related entities keeping serialization off. For this we need to make explicit call to load related entity.

404.3 - IIS - Not Found The page you are requesting cannot be served because of the extension configuration

Normally this error comes when you try to run any application on IIS for the first time. This error could be with any of the following type of requests:

  1. Asp.net website - It means you are trying to run normal asp.net website.
  2. Web Service - When you try to host web service on IIS.
  3. WCS Service - When you try to host WCF Service on IIS.
To resolve this error:


  1. Click the Start button, and then click Control Panel.
  2. Click Programs, and then click Programs and Features.
  3. On the Tasks menu, click Turn Windows features on or off.
  4. In Role, select and IIS.
  5. In features, select .net framework 4.5 features > WCF Services > HTTP Activation.
  6. Save the setting.


Friday, October 16, 2015

SQL: Stored Procedure vs Function - Difference

Following are the difference between sql stored procedures and sql functions

Stored Procedure Functions
Can return 0 or multiple values Function must return a value
SP can call functions Functions can not call SPs
Allow SELECT + DML(INSERT/UPDATE/DELETE) Allow SELECT operation only
Cant not be used in SELECT statements Can be used in SELECT statements
Cant not be used in WHERE/HAVING clause  Can be used in WHERE/HAVING clause
SPs can have INPUT and/or OUTPUT parameters Functions can have input parameters only
This is a precompiled set of statements, hence Compile statements everytime.
Transactions can be created in SPs Transactions can not be created
Allow TRY CATCH blocks Does not allow exception handling

Tuesday, October 13, 2015

IIS Error 403.14 Content listing disabled

This error is due to content listing IIS default settings. By default IIS does not allow to show directory listing of server. This is due to security permissions. This can be resolved by checking enabled directory listing checkbox in website in IIS. However it is not suggested to do so. simply write complete url of the page to access page. For example use http://localhost/default.aspx instead of http://localhost/