Prior to .NET 3.5, we (developers) often used to write ADO.NET code or Enterprise Data Access Block to save or retrieve application data from the underlying database. We used to open a connection to the database, create a DataSet to fetch or submit the data to the database, convert data from the DataSet to .NET objects or vice-versa to apply business rules. This was a cumbersome and error prone process. Microsoft has provided a framework called "Entity Framework" to automate all these database related activities for your application.
Entity Framework is an open-source ORM framework for .NET applications supported by Microsoft. It enables developers to work with data using objects of domain specific classes without focusing on the underlying database tables and columns where this data is stored. With the Entity Framework, developers can work at a higher level of abstraction when they deal with data, and can create and maintain data-oriented applications with less code compared with traditional applications.
Official Definition: “Entity Framework is an object-relational mapper (O/RM) that enables .NET developers to work with a database using .NET objects. It eliminates the need for most of the data-access code that developers usually need to write.”
The following figure illustrates where the Entity Framework fits into your application.
As per the above figure, Entity Framework fits between the business entities (domain classes) and the database. It saves data stored in the properties of business entities and also retrieves data from the database and converts it to business entities objects automatically.
SaveChanges()method. EF also provides the asynchronous
Microsoft introduced Entity Framework in 2008 with .NET Framework 3.5. Since then, it released many versions of Entity Framework. Currently, there are two latest versions of Entity Framework: EF 6 and EF Core. The following table lists important difference between EF 6 and EF Core.
|EF Version||Release Year||.NET Framework|
|EF 6||2013||.NET 4.0 & .NET 4.5, VS 2012|
|EF 5||2012||.NET 4.0, VS 2012|
|EF 4.3||2011||.NET 4.0, VS 2012|
|EF 4.0||2010||.NET 4.0, VS 2010|
|EF 1.0 (or 3.5)||2008||.NET 3.5 SP1, VS 2008|
Learn more about EF 6 versions history and its features here.
|EF Core Version||Release Date||Target Framework|
|EF Core 7.0||Nov 2022||.NET 6|
|EF Core 6.0||Nov 2021||.NET 6|
|EF Core 5.0||Nov 2020||.NET Standard 2.1|
|EF Core 3.0||Sept 2019||.NET Standard 2.1|
|EF Core 2.0||August 2017||.NET Standard 2.0|
|EF Core 1.0||June 2016||.NET Standard 2.1|
Learn about the basic workflow while working with Entity Framework in the next chapter.