Code First in Entity Framework
September 4, 2012

Code First in Entity Framework

There are two .Net ORM approaches natively supported by Microsoft: Linq2SQL and EntityFramework. While the future of the Linq2SQL is unknown EntityFramework is being actively developed.

EntityFramework provides a whole bunch of advanced ORM features including a large variety of supported mappings, a useful model designer, and auto-generation of model classes. But a lot of developers don’t like all this heavy stuff, which requires careful separation of auto-generated code from custom code, and dealing with a visual editor and huge XML files, which is in fact less productive for developers than simple code writing.

That is why, starting from EF4.1, the Code First approach appeared alongside the DB First and Model First approaches, as a natural resolution of the problem.
This approach enables writing simple POCO (Plain Old CLR Objects) model classes first and then connecting those POCO classes with the database very easily by using the the DbContext class.

References to other POCO objects and collections are recognized automatically as object relations including many-to-many. To override and extend standard mapping rules, Fluent API or/and Data annotations are used.

A lot of developers also find Code First approach very useful in case of multiple DB support – you don’t need to regenerate any models – just use a new connection to the DB.

Recently Entity Framework 5.0 has been released. This version provides some performance enhancements and a list of new features, such as support of enums and table-valued functions (only available when writing an application that targets .NET 4.5). Mapping to stored procedures is still not supported.

Tags

News

Share


Recent Articles

More Value with Lightning Value Providers

February 15, 2019 | Bohdan Dovhan, Senior Salesforce Engineer

Salesforce cloud platform offers the whole variety of customization options. Those include point-and-click tools like Lightning App Builder, Process Builder, Visual Flow and Workflow alongside development tools like Apex, Visualforce, Lightning Aura Components, Lightning Aura Events, Lightning Aura Tokens, Lightning Aura Standalone application and Lightning Web Components. Lightning Aura Components development involves the development of […]

Hot in Salesforce Marketing Cloud: January 2019 Release Notes

February 8, 2019 | Ihor Shupeniuk, Salesforce Engineer and Marketing Cloud Specialist

In the era of intelligent marketing with the proliferation of technology where modern consumers are offered the widest choice, Marketing Cloud is sometimes named a future-looking service, We continue to closely follow the developments and improvements to  Marketing Cloud and we can safely affirm that this product is becoming better and better. Everyone who has […]