Giter VIP home page Giter VIP logo

learnentityframeworkcore5.com's Introduction

Introduction of Entity Framework Core

Entity Framework is Object Relational Mapper developed by Microsoft to simplify the working of .NET developers. Entity Framework Core is a lightweight, extensible, and open-source software like all the previous versions of the Entity Framework. It is a cross-platform software making it agile to be functional on different operating systems like Windows, Mac OS, and Linux OS.

  • Entity Framework Core performs create, read, update, and delete operation automatically without the need of writing all the SQL queries manually every-time.
  • Entity Framework Core works on the principle of ORM which allows it to drop the need for writing all the access code that the developers usually had to spend so much time writing.
  • This way all the developers can focus on their ongoing project effectively and efficiently without worrying about writing all the .NET and SQL queries.

Entity Framework Core Approaches

Currently, the Entity Framework Core supports two development approaches, Code First approach, and Database-First approach, yet there is very little support available for the database first approach.

  • But for the code first approach, Entity Framework Core has proven to be effectively useful.
  • With code first approach the Entity framework Core first creates the classes for the given data and then it uses the default conventions which can be changed by users' need, it uses these conventions to create relevant database and database tables.
  • For the database first approach, EF Core creates the required classes by using the available database or database tables, it creates these classes using the EF Core commands.
  • But, the drawback of the database first approach is that this method can be applied to only limited numbers of classes as the EF Core does not support visual designer or wizard.

Features

If you are familiar with Entity Framework 6, the EF Core consists of all the features from EF 6, Some of the basic features that are included in the Entity Framework Core are:

  • DbContext & DbSet
  • Data Model
  • Querying using Linq-to-Entities
  • Change Tracking
  • SaveChanges
  • Migrations
  • Easy relationship configuration
  • Batch INSERT, UPDATE and DELETE operations
  • In-memory provider for testing
  • Support for IoC (Inversion of Control)
  • Unique constraints
  • Shadow properties
  • Alternate keys
  • Global query filter
  • Field mapping
  • DbContext pooling
  • Better patterns for handling disconnected entity graphs

Besides these features, Entity Framework Core has been recently updated to have the support for the following features as well.

LINQ Overhaul

LINQ allows developers to write an unlimited number of different .NET queries of their choices. It helps in having rich type information that offers IntelliSense and compile-time type checking, but the real challenge is to handle these combinations for LINQ providers.

  • The newer EF Core 3.0 allows LINQ providers to translate more numbers of queries into SQL, giving the user more efficient queries in SQL and letting in-efficient queries remain undetected.
  • It also allows developers to create a single SQL statement per LINQ query. Although it can have further improvements which will bring more performance upgrades in the future.

Cosmos Database Support

For developers who are familiar with Entity Framework, Cosmos DB support enables them to target the Azure Cosmos DB as an Application database.

This allows the .NET developers to have access to features like global distribution, always-on availability, elastic scalability, and low latency.

Lazy Loading

Lazy loading allows the EF Core to take the required data without writing extra queries for the same.

  • To apply this, it uses the proxies but since proxy logic isn’t the core feature of the EF Core, it keeps the data in its own package of the project.
  • With lazy loading enabled on the context, any virtual-navigation property is overridden under the covers by the proxy at run time, the developer has to manually change the declaration to virtual.

Reverse Engineering of Database Views

Those query type which represents data are readable from the database, but they cannot be changed or updated, these queries have been renamed to key-less entity types.

EF Core now automatically creates key-less entity types when reverse engineering of database views.

Entity Framework Core is continuously getting new and better firmware updates which are adding more useful features for developers, some of the upcoming features for the Future are:

  • Ability to ignore parts of a model in migrations.
  • Property bag entities tracked as two separate issues.

Example of The Entity Framework Core

In a typical situation to read, write, update, and delete from the database table, the developers must write different code to generate the SQL operations.

When the data is read from the database, in order to map the data to the relevant classes, the developers must generate another custom code to map the data to their respective classes.

All these actions must be performed for each individual project making it complicated and time-consuming for the developers.

With the help of an Object Relation Mapper like the EF Core, all these tasks can be done automatically making it simple and time saver for all the .NET Developers.

EF Core sits between application code and database and it eliminates the need for the custom data access code that usually had to be written when proper ORM solutions were absent.

Example: In case we have to develop an application to manage the employees in a company, we will have different classes like employees, departments, positions, etc. These classes will be called as domain classes.

To arrange all these classes in a systematic and structured order, any developer would have to invest a lot of time and effort to create suitable codes for the following situation.

In this case, an ORM like the EF Core comes really handy as it does all the work automatically, resulting in saving lots of resources.

Conclusion

Entity Framework Core is very useful yet agile software which sits between different category of classes and the databases or database tables to automatically configure the SQL statements needed to restructure and manage the given databases.

It simplifies the work of the developers by developing the data on its own, which allows the user to do their work more efficiently and effectively.

Since its a cross-platform software, any .NET developer can have the benefits of the Entity Framework Core.

With the on-going development happening to the Entity Framework Core, developers can expect useful and amazing features making their way to future firmware releases.

learnentityframeworkcore5.com's People

Contributors

jonathanmagnan avatar waqasm78 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.