Posts

Showing posts from May, 2013

Entity Framework Step By Step 3 – Model First

Image
As I have discussed in my previous post we know how to create a Database using Entity Framework Model First framework. In this post we’ll see how to read & write data using EF. When you create the Database using the designer, entity classes which we can use to access the data will be automatically generated in your solution. Please see the highlighted classes in the screen shot below. BloggingModel.Context.cs :- Represents a combination of the Unit-Of-Work and Repository patterns and enables you to query a database and group together changes that will then be written back to the store as a unit. Blog.cs & Post.cs :- Entity classes with properties defined in the database table. Writing Data static void WriteData()       {           using (var db = new BloggingContext())           {               // Create and save a new Blog               Console.Write("Enter a name for a new Blog: ");               var name = Console.ReadLine();               var blog = new

Entity Framework Step By Step 2 – Model First

Image
We’ll see how we can user Model First Development workflow of Entity framework with a very simple example in step by step so you can easily understand the concept. Pre-Requisites 1. You will need to have Visual Studio 2010 or Visual Studio 2012 installed to complete this walkthrough. 2. If you are using Visual Studio 2010, you will also need to have NuGet installed. Step 1:  Create Application 1. Create New Console Application. 2. Name it as “ModelFirstSample” Step 2:  Add Entity Model item to project 1. Right click on the project & select add new item. 2. In the new item selection menu select “ Data ” then select “ADO.net Entity Model”. 3. Name the item as “ BloggingModel ” 4. Then in the Entity Data Model Wizard select “" Entity Model ” click finish. Step 3:  Create Model Right-click on the design surface and select Properties In the Properties window change the Entity Container Name to BloggingContext Right-click on the design surface and sel

Entity Framework Step By Step 1

Image
Thought of writing a series of posts to explain entity framework Step by step so that anyone can easily understand the concepts behind that. This will be the starting point of that. What is Entity Framework? “Entity Framework (EF) is an object-relational mapper that enables .NET developers to work with relational data using domain-specific objects. It eliminates the need for most of the data-access code that developers usually need to write.” As the first step to begin entity frame work the first thing we have to do is to identify which workflow we should adopt. Entity Framework provides 4 different workflows we can adopt for our development based on our requirement.   Which Workflow We should Adopt?   When deciding which workflow we should select there are four question we should answer. 1. Are you targeting new Database , which is empty & tables need to be created? 2. Are you targeting existing Database where tables are already populated? 3. Would you prefer cre

IntelliTrace On Production

Image
Now you can use IntelliTrace Collector create IntelliTrace logs in your production environment where you don’t have visual studio Installed . Collector supports the following Apps ASP.NET Web apps hosted on Internet Information Services (IIS) version 7.0, 7.5, and 8.0 SharePoint 2010 and SharePoint 2013 applications Managed desktop apps (.exe files) Lets see step by step now we can set up this in the production environment. Step 1: Install Collector 1. In your server create a Folder. ex: C:\IntelliTraceCollector 2. Download the collector from Microsoft download center. Click Here 3. Copy the IntelliTraceCollector.exe to the folder created & run the IntelliTraceCollector.exe. 4. Then expand IntelliTraceCollection.cab    I. Open windows command prompt as an administrator    II. Go to collector directory. ex: cd C:\IntelliTraceCollector    III. Run the following Command : “ expand /f:* IntelliTraceCollection.cab .” Step 2: Set Permission to collector Directory R

Intellitrace

Image
IntelliTrace is a tool available in Visual Studio which gives developer the facility of record the data of their debugger session. It provides options for developer to rewind the debug & see what exactly happening in the code. In traditional F10 & F11 debugging it gives the very limited data on history data of the debugging session so that we have to re-debug the code in a case where we missed anything. This IntelliTace can be defined as a time machine because it enables the developer to travel through the debugger session data. IntelliTrace Collects Data On IntelliTrace events Method calls and exit points Breakpoints & Tracepoints IntelliTrace also allows you to debug the errors in the production environments where you do not have visual studio installed. I’ll provide more details on that in my next post. Step 1: Open IntelliTrace Settings Debug –>IntelliTrace –>Open IntelliTrace Settings Step 2: Configure Intellitrace Settings Debug –>IntelliTrace –&

Pinnable Data Tips

Image
  Pinnable Data Tips are one of the most interesting features available in Visual Studio  for make developers debugging life easier. When using traditional debugging if when we need to see a value of a object we have to take the mouse point to the variable & get value. But with the Pinnable data tips that is no longer needed. Following Screen shot illustrates how we used to see the values inside the object when using traditional debugging.So even when we are at some lines below the code which the object value is we have to always take the mouse there. Also we are suable to see values of multiple objects. Now you can create a Pinnable Data tips in visual studio which you can see the value in a data tip pinned on your visual studio UI. You can create the data tip by clicking on the option highlighted in the following screen shot. After Creating a Data tip you have the facility of adding a comment to that data tip & drag & place the data tip in any location in the scree