EF Core Introduction

Welcome to learning EF Core with me. Though there are good number of theoretical resources online, very few helps with practical hands-on examples. In this tutorial, we will go through the concepts of Entity Framework Core 3 with real world examples and the corresponding input/output screens.

Why Core

Well. every .NET programmer knows today that the native .NET framework till 4.x is robust, stable and secure. Core is not. As we speak, Microsoft is working on releasing newer versions of core only to make it more stable. But why is there a need for a new framework altogether? The short answer is cloud. Every other technology is providing scalable cloud solutions as it is the future. Microsoft does not want to stay behind and it wants an architecture to mingle well with their cloud platform, Azure. Also, Core is open source and cross plaform, meaning it now supports Unix, Linux, Windows, etc. Microsoft Azure guarantees 99.9% availability. But this can be achieved when the consuming application is lightweight and the repositories are centralized.

NuGet

Core takes care of assemblies with Nuget as centralized repository hub. So developers need not worry about the assembly versions and deployment. Everything is done with Nuget. It can update the installed libraries through its platform and while deployment, the cloud or hosting platform can obtain the referenced assemblies through Nuget.

ORM

Object-Relation Mapping(ORM) is the solution which simplifies the process of working with back end database. The databases can be Oracle, SQL, MySQL, etc and the ORM framework can be Entity Framework, nHibernate, etc. Since SQL is the microsoft product, Entity Framework is the microsoft’s solution to ORM.

ORM is built on top of ADO.NET. It is not a replacement on ADO.NET. You can think of it as a wrapper that provides ADO.NET functionality and objects can access it through the context. It provides support to Read, Insert, Update and delete and other database operations. You can use Object oriented concepts and the power of ORM to communicate with your database.

ORM is slow but more secure

Yes, there are some performance issues because it is an extra layer on top of ADO.NET. But it is more secure, meaning it internally prevents Penetration attacks like SQL injections. Objects fires commands through context and it internally queries the database through its interface. All the queries can be debugged using SQL profiler.

EF CORE 3.x

Though, EF 6 is more stable and heavy. EF Core 3.x is more lightweight and comes with needed features like contexts, data model, change tracking and save change. It does not include the support for EDMX model. But includes batch insert, update , deletes, in-memory testing, shadow properties, etc. You can use EF Core in .NET Core applications and the assemblies can be installed through NuGet package manager console.

In this tutorial, we will go through each concept in Entity Framework core with practical concepts.

Please contact me if you need more help or associated project files in the tutorials. I am available for anyone who needs my help in technical challenges.