How to use DebugView to Log Entity Framework

In this post I will show you to use DebugView to log the Entity Framework. For detail discussion on the same topic you may want to learn more here:

Logging in Entity Framework on Steve Smith Blog

Profiling Database Activity in the Entity Framework by Julie Lerman

Download DebugView , unzip it and Run it as administrator. In Capture menu select the options as shown in below image,

image

Once the debugview is configured, you should configure the DataContext class as shown below. Enable database log to print on the debug window.

image

As the last step run the application using Entity framework without using Visual Studio or without attaching Visual Studio Debugger. In Visual Studio run the application using Ctrl+ F5. You should able to view the Entityframework log in Debugview as follows:

image 

The Debugview can be your good friend when you stuck with performance issues and want to log the queries.

Happy Coding.

Unable to index file: Permission Denied error in git add command

While working on an application, I had to commit changes to local Git Repository. It was usual task and I started with following command,

git add –A

To surprise git add command gave me error as shown in image below. Error message was clear that to a particular file there was Permission denied.

clip_image002

Note: I was working on a MVC application which had local database attached. Name of database was MoviesRTM.mdf.

I tried to commit using Visual Studio 2013 as well. Here also I got same error as shown in image below,

clip_image004

This can be solved by two ways either shutting down IIS Express or restarting Visual Studio. I was using IIS Express to host MVC application. You can shut down IIS Express by right click on IIS Express and click on Exit from context menu.

clip_image006

If this option is not working then try restarting Visual Studio.

Note: Restarting Visual Studio or Shutting down IIS Express may worked in this scenario because permission denies error was on a database file (extension mdf). And database was locally created.

After shutting down I was able to run git add command successfully.

Happy coding.

Getting Started with Git and GitHub

 

 

Read complete article on Falafel Blog

Who is not talking about Git or GitHub? In one of our recent user group meetings, someone asked how many Pull Requests have you done so far in any of open source projects on GitHub. I realized many developers in the room were puzzled with the phrase Pull Request. In this post I will explain some basic Git terminology and explore basic Git commands which will help you get started with Git. In a later post I plan to show you how you can work with Git-based Source Control and Visual Studio 2013.

Let us start with understanding basic terminologies:

Repository

A Repository  is a space where projects reside. Repository can be on a local computer or at an online host like GitHub or Team Foundation Server (TFS). If you are working in project then a Repository is basic unit of working . It will contain all the files, images etc. needed for the project. It should always contains a readme file, which describes the project

Read complete article on Falafel Blog

Lenovo ThinkPad T440P: My next companion

image

A batsman grow with his bat, a writer grow with his pen and a programmer grow with his machine. I was my gifted my first desktop by my father back in year 2003. That was assembled desktop with following configurations,

Processor: Pentium 3 1.7 GHz ||RAM: 128 MB || Hard Disk: 40 GB || 17 inch monitor || Assembled

I wrote first program on that assembled desktop and since then have worked on different kinds of desktops and laptops. I have worked on Dell Latitude, Lenovo ThinkPad etc. but never own them. On Friday 9th May 2014, I bought new machine for me. After bit of research online, for me Lenovo ThinkPad T440P came as a best choice for this time. This is one of the best available in market at this given time.

clip_image002

First thing you will notice is, it is not very sophisticated machine. In look it is very raw and a feel is guaranteed when you type codes using its keyboard.

Configuration of this machine is as follows,

Processor: Intel i7, 4th Generation||RAM: 16 GB || Hard Disk: 500 GB || 14 inch display || l3 cache || Windows 8 professional || Lenovo

 

clip_image004

One of the best is its keyboard and supported 1366*768 resolution display. Due to 14 inch screen size it is small and light. If you are a frequent traveller, this is your machine.

clip_image006

This machine is available in Lenovo stores throughout India. Rather buying it online, I bought it from a Lenovo store in NCR. I am very excited for my new companion Lenovo, ThinkPad T440P. Now why I am waiting let’s start coding.

First look of book: Designing Evolvable Web APIs with ASP.NET by Glenn Block

In India order this book from Amazon here

You become what you read

In this era of Kindle, tablets and EBooks, I proudly consider myself as real book lover. I get more connected to real book than any EBook on any trendy device. In order to purse my passion of collecting good books, toady I got WEB APIs book with ASP.NET by Glenn Block. Even before I start learning from this book, I am sure this book will teach me many good things about HTTP, REST and WEB API.

I got book delivered from Amazon this afternoon. It is summer in Delhi and the Sun it at its best yielding temperature 45 degree centigrade. I had to go out in this weather to collect book but trust me it was worth going out.

clip_image001

I thank from bottom of heart to Glenn Block for this wonderful gift. I can’t express in words that how I am going to enjoy and learn this book.

This book got great credential since it is authored by veterans like Glenn Block Pablo Cibraro pedro Felix Howard Dierking Darrel Miller

clip_image002

In India order this book from Amazon here

There are 17 chapters in this book. They are as follows,

  1. The Internet , the World Wide Web , and HTTP
  2. Web APIs
  3. ASP.NET Web API 101
  4. Processing Architecture
  5. The Application
  6. Media Type Selection and Design
  7. Building the API
  8. Improving the API
  9. Building the Client
  10. The HTTP Programming Model
  11. Hosting
  12. Controllers and Routing
  13. Formatters and Model Binding
  14. HTTP Client
  15. Security
  16. The OAuth 2.0 Authorization Framework
  17. Testability

I am fortunate to see evolution of WCF SOAP to WCF REST to Web API. I have not started reading yet but at the very high level I perceive this book as one of the greatest guide to learn HTTP Services. This book helps to create Web APIs harnessing the power of HTTP. I strongly recommend this book, if you are willing to create REST Services.

Our hero Scott Guthrie is also impressed by this book and he has said something like below about this book,

clip_image002

So what are you waiting for? Go and grab your copy and start learning and coding. Great job by Glenn and other authors.

In India order this book from Amazon here

Completed 6 years in Software Industry

image

 

24th March is very important date in my life. I started my journey as professional or in simple words I started working on 24th March 2008 after passing engineering in June 2007. Hence today I have completed 6 years as working professional. This has been an exciting journey. In these 6 years, I worked on various projects, under different managers, in three different companies in three different cities. When I look back, I find myself different than what I was on 24th March 2008. I must say this journey has changed me lot.

I have worked for these three companies so far,

image

On 24th March 2008 I joined UST Global as trainee Software Engineer and worked there till September 2010.

On 10th October 2010 joined Infosys as Senior System Engineer and worked there till June 2012.

On 2nd July 2012 joined Telerik as Developer Advocate and since then working here.

If you are reading this post then you must be knowing that I love to share my learning via my blog. I love blogging and I am sure you also (in case if you) love me for my blog and articles. In last 6 years my journey of blogging is as below,

 

image

 

Clearly seeing above chart you can conclude that I am getting old and momentum of writing posts are getting reduced. Oh God! Help me! I promise to meet your expectation and product quality posts in regular interval.

Whenever I get opportunity I speak in conferences, user groups, colleges. In these 6 years I have delivered around 50 sessions.

image

In these six years, I have been awarded as Microsoft MVP 4th times, C# Corner MVP 4th times and Telerik MVP 1 time.

 

image

would take this opportunity to thank each one of you for your support in my journey. In coming years I will focus on Cloud, Node.js, JavaScript and other technologies.

Single Responsibility Principle in C-Sharp: Simplified

Let us start with understanding what is SRP?

Single Responsibility Principle says every class should have single responsibility and all the responsibility should be encapsulated in the class. To explain it further assume you are creating a creating class to Calculate Salary.

Now if you have two methods in class like below. Usually we can think of these two methods in a Salary class.

  1. CalculateSalaray
  2. PrintSalary

So you can say there are two responsibilities to class. With two responsibilities Salary class can be defined as below,

 class Salary

{
 public double wageperday { get; set; }
 public int attendence { get; set; }
 public double CalculateSalaray()
 {
 return this.wageperday * this.attendence;

}

public void PrintSalaray()
 {
 Console.WriteLine(this.wageperday * this.attendence);

}

}


As of Martin SRP means, “Class should have a single reason to change”. Reason to change can be seen as a Responsibility. On seeing closely you will find above class has two reasons to change,

  1. When formula for calculate salary is changing
  2. When print logic is changing

Since Salary class has two responsibility so there are two reasons to change it. We can say Salary class is not following Single Repository Principle.

We can summarize that

image

Next we need to find that how could we divide two responsibility in two separate class. So above Salary class can be divided into two separate classes. One class to CalculateSalary and another to PrintSalary.

Below is the class CalculateSalary. This class got only one responsibility to calculate salary.

class CalculateSalary
 {
 public double wageperday { get; set; }
 public int attendence { get; set; }
 public double CalculateSalaray()
 {
 return this.wageperday * this.attendence;

}
 }

 

Another class is PrintSalary. This class also got only one responsibility to print salary.

 class PrintSalary
 {

public void PrintSalaray(double salary)
 {
 Console.WriteLine(salary);

}
 }

Let us understand what we done now is divided Salary class in two separate classes. Salary class had two responsibilities and two reasons to change. Now we have created two classes respectively for CalculateSalary and PrintSalary.

image

Now at client these two classes can be used as below,

static void Main(string[] args)
 {
 CalculateSalary clcObject = new CalculateSalary();
 clcObject.wageperday = 300;
 clcObject.attendence = 20;
 var salary = clcObject.CalculateSalaray();
 PrintSalary prntObject = new PrintSalary();
 prntObject.PrintSalaray(salary);
 Console.ReadKey(true);

}

As of now you should have idea about Single Responsibility Principle. To summarize Single Responsibility Principle says a class should have single responsibility and only one reason to change. I hope you find this post useful. Thanks for reading.