What is Entity Framework?
Entity Framework (EF) has been an important part of the Microsoft development platform for several years now. It’s what’s known as an Object Relational Mapper (ORM); that is, it maps objects defined in source code to tables in a relational database. ORMs have existed in various languages and on various platforms for years now. They automate tedious database query logic and make it easier to keep your source code and your database in sync.
When EF was first released in 2008 along with the .Net 3.5 SP1 Framework it was widely maligned by the development community. It lacked many of the important features offered by its competitors and those it did have were buggy, slow, and unintuitive. But over the years Microsoft has responded to feedback and filled in the gaps. By the time EF6 was released in 2013 it offered a stable, robust feature set and the case was strong for EF in side-by-side comparisons.
What is Entity Framework Core?
In the past, Microsoft has received a lot of flak from the development community for the Windows-only nature of their tools and the open hostility they expressed for open source software. All that has been changing in the past few years, though. Under the leadership of CEO Satya Nadella, Microsoft has made a big push to make their tools and frameworks cross-platform and open source.
It’s no surprise, then, that EF would get the cross-platform, open source treatment. Originally dubbed “Entity Framework 7”, the name was ultimately changed to “Entity Framework Core”, because this latest version is not an enhancement on the original EF, but rather a complete rewrite from the ground-up. The feature set for EF Core is very different than that of EF6, and existing EF users need to be aware that switching from one to the other is no small task in an existing project. But for new projects, especially ones that leverage Mac and Linux tools, EF Core is worth consideration.
What’s the Difference?
EF Core boasts several useful features that are absent in EF6. Among these are shadow properties, which are tracked properties that do not exist in the underlying entity class, client-side primary key generation, LINQ queries containing raw SQL, and mixed client/server evaluation of queries. It also ships with an enhanced command line interface, making it easier for developers that are used to working primarily in the terminal. But the feature that will be most welcome to developers is the ability to use the framework in non-Windows environments.
Because EF Core is so new and it is a complete rewrite it is still missing many of the features that developers have grown used to in EF6. Updates are being released to fill in the gaps, so most of these will be addressed eventually. In the meantime though, these absences will lead to frustration and should be considered before adopting EF Core for your project. Among the missing features are many-to-many relationships without a “join” entity, lazy loading of related data types, seed data population, and stored procedure execution.
Entity Framework 6 is a stable, feature-rich product that has an abundance of documentation and support online. If you’re on a team of developers working exclusively in a Windows environment with Windows tools there’s no reason to change right now.
But Entity Framework Core is the future of the product. If you want to stay ahead of the game and don’t mind working with a product that’s still rough around the edges you should consider it for your smaller projects. Additionally, if you’re planning to use Mac or Linux tools or if you’re planning to deploy to one of those environments, then EF Core is worth a look. The features aren’t all there yet, but more are coming with each update.
Microsoft did not release EF Core in isolation. .Net Core 1.0 was also announced as a cross-platform alternative to the traditional .Net Standard platform. Around the same time, Microsoft announced a partnership with Docker, the popular containerization software. These and other cross-platform, open source announcements from Microsoft are a part of a new vision for a streamlined development process that leverages not only Microsoft tools but any tools and frameworks that a developer wants to make use of. Adhering to standards and welcoming integration via open source contributions makes these new tools, EF Core included, a part of a burgeoning new development ecosystem. Microsoft has made it clear that they finally believe that cross-platform and open source are the way of the future.