Posts Tagged ‘DotNet’

NHibernate Vs Entity Framework 6.0 – A Comparison

December 3, 2013

Here is a nice comparison table for NHibernate and Entity framework 6.0. This is the result of my searching and reading, to get to know over the evolution of Entity Framework (the latest is V6.0). Enjoy reading!



EF 1.0 to EF 6.0

Current version


V 6.0

Year released

 Hibernate (JAVA) 2001/ NHibernate (.NET) 2005



.NET 1.1 and above/Mono

.NET Framework 3.5 SP1 and above

Open source


Yes from 6.0


Both supports 1 to 1, 1 to many, and many to many

Both supports  1 to 1, 1 to many, and many to many

Rich domain models



Ordered and unordered sets collection. Indexed options. It even has an immutable, indexed list



Mapping private fields (yet) or can you directly use a dictionary class



Collection supports

IDictionary<T,T>  IEnumerable<T>


Supporting ENUM


Yes from 6.0

Vendor support /Providers:

SQL Server/Azure, SQLite, PostgreSQL, Oracle, Sybase, Firebird and DB2

All the DB providers are built-in

SQL Server or SQL Azure,

Code first


From EF 5.0

Code-based mapping

NHinernate 3.2 with Fluent-NHibernate

From EF 6.0

Supporting custom types and collections



Query flexibility

HQL/QueryOver/Criteria API/Native Vendor specific SQL (3.2 with the above & lot more)

LINQ/Entity SQL/Native SQL/Commercial  provider for ORACLE


Uses Listeners/Configuration properties

ServiceLocator pattern

Async/await support


EF 6

Built-in support for automatically reconnecting to the database



.NET 4.5 support


Yes (with improved performance)

Batch processing

With “Future”


Creating a DBContext with an existing open connection



Spatial support

Need 3rd party



Poor, but can get lot of support over forum



Support second-level caching

Yes from EF6


“NHibernate has a very rich event model, that exposes more than 20 events, either for synchronous pre-execution or asynchronous post-execution”.

Entity Framework only has two event-based extension points: ObjectMaterialized and SavingChanges

Tracking Changes


While both default to change tracking at the unit of work level, Entity Framework also offers self-tracking entities.

Able to map SQL views



Querying SSAS OLAP cubes



Interception of queries/object creation



API Methods

Save, Update, SaveOrUpdate, SaveOrUpdateCopy, Replicate and Merge,


Lazy loading behavior

One an relationship by relationship basis

For the entire context


Misleading exception with .NET DataContractJsonSerializer() – A bug reported to

December 3, 2013
Please find below the complete text from
Note: Just copy pasted  as is, so that you may not be finding formatted nicely. 🙂
I was working for serializing C# object into JSON using DataContractJsonSerializer(). Whenever the KnownType in not specified in the base class or passed into the constructor of DataContractJsonSerializer(), I have got the following exception.[Exception]
An unhandled exception of type ‘System.Runtime.Serialization.SerializationException’ occurred in System.Runtime.Serialization.dllAdditional information: Type ‘DerivedClasses.CustomerResponse’ with data contract name ‘CustomerResponse:; is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types – for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.


Visual Studio/Visual Studio Online/Team Foundation Server/.NET Framework Tooling Version

.NET Framework 4.5.1

What category (if any) best represents this feedback?


Steps to reproduce

1). Have a base class and derived class
2). Don’t mark the base class with [KnownType] attribute
3). Populate derived object with required data
4). Try serializing derived object to JSON using DataContractJsonSerializer(), by passing the typeof(base class)

Product Language


Operating System

Windows 7

Operating System Language


Actual results

Issues with the exception:The exception what we are getting is as same as for “DataContractSerializer”.

So, this exception message is misleading by saying
1). “Consider using a DataContractResolver”, though DataContractJsonSerializer() is not supporting DataContractResolver.
2). or by adding them to the list of known types passed to “DataContractSerializer”

Expected results

The above two points in “Actual results” section needs to be removed from the exception and to be corrected with specific to “DataContractJsonSerializer”.


English Connect
Posted by laks_win on 12/2/2013 at 10:49 AM

Hi Team,I have got one more issue on the same Misleading exception with DataContractJsonSerializer() for passing the object which has “Cyclic References”. Actually DataContractJsonSerializer() doesn’t support it, but shows the exception that is specific to DataContractSerializer(). So, please have a check for this issue too.

Thanks and regards

Posted by Microsoft on 11/8/2013 at 2:39 PM

Hi Laks_win.Thank you for the feedback on WCF. This is a good suggestion and we will consider this for a future release.

Erica Mohler
Microsoft Program Manager

Posted by Microsoft on 10/29/2013 at 4:04 AM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by laks_win on 10/24/2013 at 9:54 PM
Thanks for the follow up. Just uploaded a newly created sample zip, its for your kind perusal.
Posted by Microsoft on 10/24/2013 at 6:22 AM

Thank you for submitting feedback on Visual Studio and .NET Framework. In order to efficiently investigate and reproduce this issue, we are requesting additional information outlined below.Could you please give us a demo project to demonstrate this issue so that we can conduct further research?

We look forward to hearing from you with this information.

Posted by Microsoft on 10/23/2013 at 10:50 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(

Features in Visual Studio 2012 and ASPNET 4.5” Free E-book

August 4, 2012

There is an E-Book available for download in Telerik’s website. This e-book contains an overview of the features that would help great you as a developer :).

So, what is in this e-book you ask? Well…..

  • JavaScript Intellisense
  • CSS Intellisense
  • ASP.NET and Web API (overview and CRUD operations)
  • Strongly Typed Data Binding
  • Page Inspector (new debugging tool)
  • Etc

Here you go…

Free E-book: Time-Saving VS11 and ASP.NET 4.5 Features You Shouldn’t Miss