Entity Framework 4.0 Code-First vs NHibernate
Microsoft’s .NET Framework Version 4 includes a version of the Entity Framework, which allows two ways of creating your model: Database First and Model First. Database First was already available for the previous version of Entity Framework. It means that Visual Studio’s Wizard is used to point to a database and Entity Framework generates the model classes and mappings out of the database tables. Very often the domain model looks different than the data model, which means either developing another mapping layer between the generated classes of Entity Framework or a lot of customization on the generated classes themselves. For this reason it is also possible to use the Model-First approach, which allows you to use the graphical designer and design your model first and then let entity framework generate the database schema and mappings. Lately another approach has been introduced as a CTP: Code-First. Instead of using the designer, Code-First allows you to code your domain with POCOs and persist this plain model using Entity Framework. This article compares Entity Framework 4 Code-First CTP with NHibernate in terms of usability (not performance-wise) using examples of domain driven design concepts.