Wednesday, June 4, 2014

How to kill all current connections to a database in SQL Server ?

In case of you want to restore an database.

There are many ways to do so.
See link on Stackoverflow
http://stackoverflow.com/questions/11620/how-do-you-kill-all-current-connections-to-a-sql-server-2005-database


Or there is another simple way:
1. In SQL Server studio, click Activity Monitor button
2. Filter by database
3. Right click to kill all of connection to that database

Monday, June 2, 2014

How to solve problem, Invalid column name 'Discriminator'?

Get this error while upgrade Entity Framework from 5.0 to 6.x.
Install Entity Framework by Nuget. The version got is 6.1

Then get this weird error: Invalid column name 'Discriminator'
All of fields for that table are in the database table, so [NotMapped] is not applicable in here

The solution to me is to revert to 6.02, problem solved.

How to solve problem, "No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'."

Entity framework is using older version 5.0 and on .Net 4.0, need to install a new one.

Go to Package Manager Console:
Run
Install-Package EntityFramework

Thursday, May 29, 2014

How to remove ASP.NET response headers Server, X-AspNet-Version, X-AspNetMvc-Version and X-Powered-By?

Need two steps:
Step 1: add following code into Global.asax
protected void Application_PreSendRequestHeaders(object sender, EventArgs e)
        {
            HttpContext.Current.Response.Headers.Remove("X-Powered-By");
            HttpContext.Current.Response.Headers.Remove("X-AspNet-Version");
            HttpContext.Current.Response.Headers.Remove("X-AspNetMvc-Version");
            HttpContext.Current.Response.Headers.Remove("Server");
        }

AND

Step 2
Add following config into web.config file