Complex type in EFCodeFirst

I have already written a few blog post about EF Code first and it’s features following is a complete list of blog posts.

Entity framework code first and inheritance- Table Per Type
Entity Framework code first and Inheritance–Table per hierarchy
Entity Framework Code First migrations
Different way of mapping with EFCodeFirst
Different way of creating keys in EFCodeFirst

This post will also be part of this EF code first series. In this blog post we are going to learn how we can handle complex type in EF Code First. In our day to day operation we are having different kind of database tables where  there are multiple type of relationships  are defined like one-to-one, one-to-many and many-to-many. This all kind of relationship is handle by complex types.

Dependency Injection with ASP.NET MVC and Simple Injector

I have been learning SimpleInjector for few days and it’s just awesome.  I have already written two post about it(see below link) and this post will be third post about it. In this post we are going to learn how we can do Dependency Injection with ASP.NET MVC.

For those who are reading my posts about Simple Injector Following are two previous post I have written about Simple Injector. I highly recommend to read first two post so that you can be aware about how we can configure SimpleInjector container.

Dependency Injection with Simple Injector
Singleton Instance in Simple Injector

So let’s start with creating a ASP.NET MVC Project from Visual Studio.

Singleton Instance in SimpleInjector

Before some time I have written a blog post Dependency Injector with Simple Injector. This is a second blog post in same series. In this blog post we are going to learn How we can create a singleton Instance in Simple Injector.

What is is Singleton:

This is one of the Gang of Four creational pattern. Idea of behind the singleton pattern is to have only one instance of class of at anytime. This pattern ensures that a class will has only one instance of it and provides a global point of access to that instance.

I have already written a global blog post about that. You can find a basic example of Singleton pattern in C# from the following link.

Singleton Class in c#

How we can create Singleton Instance with SimpleInjector:

Here I’m going to create a console application with logger example. So let’s create via creating a new project like below.

Dependency Injection with Simple Injector

Before some I have written a blog post about how to do dependency injection with StructureMap. In this post we are going to learn Simple Injector IOC library and how we can do dependency injection with Simple Injector.

About Simple Injector:

Simple Injector is a open source dependency injection library developed with C#. Followings are few characteristics of Simple Injector.
  • Simple Injector is very simple to use dependency injection library support .NET 4+ framework, Silverlight 4+, Windows Phone 8, Windows 8 Including Universal apps and Mono.
  • Simple Injector is easily integrated with frameworks like ASP.NET Web Forms, ASP.NET MVC, ASP.NET Web API, WCF and many more.
  • It’s free and always be free. Published under MIT license.
  • Simple Injector is highly optimized for performance and concurrent use.
  • Simple Injector is thread safe and lock free design.
  • Simple Injector has great support for generics and used lot of things of generics then any other dependency injection libraries.
  • Simple Injector has a powerful diagnostic system.Currently it offers following validations
    • Lifestyle Mismatch
    • Short Circuit Dependencies
    • Potential Single Responsibility violations
    • Container Register Types
  • Simple Injector is amazingly fast.
  • Simple Injector is developed using Modern proven development practices such as TDD and Solid Design Principals. like URLs with attribute routing in ASP.NET MVC

Before some time I have blogged about Attribute Routing features of ASP.NET MVC 5.x version.  In this blog we are going to learn how we can create like URLs with attribute routing.

As you know is one of the most popular questions answer site where you can ask questions and almost get the answers of your questions. So to create URLs like we need to understand structure of URLs of Stackoverflow. Let’s take example of following question URL which I have answered on

and let’s take another example

If you compare and understand structure of this URLs. You will know that there will be a two things which will be dynamic for this URLS.

Blog post selected as ASP.NET MVC Official Additional Learning Resources

I have got news before few days that my blog post about CDN is ASP.NET MVC bundling selected as Additional Resources for learning about ASP.NET MVC on official ASP.NET Site.

On this occasion I would like to thank my audience and my family to supporting me. Thank you all without you it would not have been possible. I loved to be part of this amazing community and I promise that I would continue to do community work.

I would also like to thank Rick Anderson and Jon Galloway and whole ASP.NET Team for selecting my post. It’s a honour for me. Thanks you very much guys for encouraging and inspiring me  to do community work!!

Due to all this my blog got high ranking and I’m almost getting more then 80k page views every month. Google is loving my blog more and more!!

Thank you very much everything dear readers!!

Different way of creating keys in EFCodeFirst

Recently I have been playing with Entity Framework Code First and I like it a lot. There are plenty of features given and you can configure all that stuff with code. I have already written couple of post for Entity Framework Code First.

Different way of mapping in EFCodeFirst
Entity Framework code first and Inheritance–Table per hierarchy
Entity framework code first and inheritance- Table Per Type

As you EFCodeFirst generate database table based on the configuration defined in classes. Today we are going to learn about how we can create key with different configurations.

CDN in ASP.NET MVC bundling

ASP.NET MVC contains great features and Bundling is one of them. The Bundling and Minification features allow you to reduce number of HTTP requests that a web page needs to make by combining individual scripts and style sheet files. It can also reduce a overall size of bundle by minifying the content of application.   From ASP.NET MVC 4 bundling also includes CDN support also where you can utilize public CDN available for common libraries. Let’s look this features in details.

CDN Support in Bundling:

Libraries like jQuery, jQuery UI and some other libraries are commonly used in most of the applications. There are available in CDN (Content Delivery Networks) specifying the URL of particular library with specific version.  Bundling now has CDN path as parameter in default bundle functionality where you can specify the path of the CDN library and use that. So when you application run in production environment first it will check whether CDN are available or not if available then it will load it from the CDN itself and If CDN is not available then it will load files hosted on our server.

CRUD Operation with ASP.NET MVC and Fluent Nhibernate.

Before some time I have written a post about Getting Started with Nhibernate and ASP.NET MVC –CRUD operations. It’s one of the most popular post blog post on my blog. I get lots of questions via email and other medium why you are not writing a post about Fluent Nhibernate and ASP.NET MVC. So I thought it will be a good idea to write a blog post about it.

What is Fluent Nhibernate:

Convection over configuration that is mantra of Fluent Hibernate If you have see the my blog post about Nhibernate then you might have found that we need to create xml mapping to map table. Fluent Nhibernate uses POCO mapping instead of XML mapping and I firmly believe in Convection over configuration that is why I like Fluent Nhibernate a lot. But it’s a matter of Personal Test and there is no strong argument why you should use Fluent Nhibernate instead of Nhibernate.

Fluent Nhibernate is team Comprises of James Gregory, Paul Batum, Andrew Stewart and Hudson Akridge. There are lots of committers and it’s a open source project.

You can find all more information about at following site.

On this site you can find definition of Fluent Nhibernate like below.
Fluent, XML-less, compile safe, automated, convention-based mappings for NHibernate. Get your fluent on.
They have excellent getting started guide on following url. You can easily walk through it and learned it.

ASP.NET MVC and Fluent Nhibernate:

So all set it’s time to write a sample application. So from visual studio 2013 go to file – New Project and add a new web application project with ASP.NET MVC.

Different way of mapping with EFCodeFirst

Recently I have been working Entity Framework Code First 6.0 and it’s awesome. I am in love with it. It has got great fluent API and we can do anything with that. It’s also promotes Convention over configuration which I love so far.

I have seen people are more confused about how we can map table to class via Entity framework via code first. So this post is going to be in same series. In this post I’m going to write about different ways to mapping table to class. I have already written two post about in details.

Entity Framework code first and Inheritance–Table per hierarchy
Entity framework code first and inheritance- Table Per Type

In this blog post I will give you tips and tricks to map class(type) with database table.