Entity Framework Core: Cross Platform ORM for .NET Core


We are just now getting into connecting to the database. This is a good time to talk about Entity Framework (EF) core. Entity Framework maps the objects of the source code to the tables of the relational database. The tedious way of connecting to DB was easily automated by EF that kept the database in sync with source code. The improved revisions of EF were comparable with open-source ORM that were cross-platform. EF core, the new version is built as open-source, cross-platform applications for .NET applications. EF Core is a light-weight, extensible, open-source consisting of multiple packages that can be installed using NuGet manager. The latest major version of EF Core is v3.0 and soon we will have next release EF Core v5.0.


The major release of EF Core v3.0 has boosting features as cross-platform ORM.


  1. Shadow Properties: There are situations where the data is not displayed in the application but are used for auditing purposes Eg: LastUpdatedDate, LastVisited, blog id. These types of properties are called Shadow Properties or Navigation, Auditing, or Tracking properties. These are helpful to create the domain models.
  2. Client-side primary key generation: Primary keys are essential to track the data from various sources. While we submit details to the database, the primary key is generated by databases. Sometimes the client creates a temporary id before submitting the details to the database. This key can be replaced by DB once it creates a new ID.
  3. LINQ to Entities: Language Integrated Queries (LINQ) queries are part of .NET framework. They provide a standard way of querying with readable syntax. Introduced in EF Core they fill the gap between relational and object-oriented approaches. They include IntelliSense and debugging support and further support the LINQ query expressions.
  4. Change Tracker: Accesses change tracking information for entity instances the context is tracking. In short, if any entity is changed the change is persisted to the database and is saved during SaveChanges(). EF core also fixes the navigation properties between entities, that is needed for tracking query.
  5. Lazy Loading: EF core can load the data and eliminates writing an additional query. This is a pattern where loading is different until its needed and in some cases, it helps in improving the performance.
  6. Data Seeding: Seeding is the process of populating the database with an initial set of data. The data seeding is required during the migration process. There are 3 ways


  1. Model seed data
  2. Manual Migration customization
  3. Custom initialization logic.


Features like Asynchronous saving, multiple Saves in single transactions, cascade delete that are quite useful for cross-platform applications. EF Core connects with databases like SQL database, MySQL, PostgreSQL, Azure cosmos DB, SQLite. By the end of 2020, we’ll have the .NET 5 that is the next version of .NET Core, along the same line we’ll be having EF Core 5 with advanced features like database collation, migration improvements. Having these frameworks will increase the efficiency and efficacy of .NET apps in a cross-platform environment.


TakeAway:

Entity Framework Core is paired with .NET Core apps. It being a cross-platform ORM, the open-source and light-weight are surely an advantage.

.NET 5 which is scheduled for the release at the end of this year will now bring all the .NET Core features as one platform and will be a big plus for .NET Apps.


At BundleN, we experiment with stack combinations on our own time.

For potential clients interested in this stack, we can always give a demo of what we have up until that point of time. You can reach us at sales@BundleN.com