EF Core Consulting

  • High performance: EF Core on .NET 6 is 92% faster than on .NET 5 and demonstrates huge gains in query performance and improved startup performance with compiled models. It is 31% faster in executing untracked queries and offers 43% reduction in heap allocation while executing queries.
  • EF Core 6 features: There is support for temporal tables, ability to update the database with stand-alone executable migrations, bulk conventions and value conversions, Azure Cosmos DB provider enhancements, DBContextFactory improvements and much more.
  • More than an ORM (Object-relational mapper): EF Core supports SQL Server, Sqlite, Postgres, Oracle, MySQL, DB2, Informix, Cosmos DB, MongoDB, Cassandra, Teradata, Google Cloud Spanner, Progress OpenEdge, Microsoft Access and many other databases.
  • Top awards: Our experts include Microsoft Most Valued Professionals awarded by the Microsoft .NET team. Our team includes Microsoft Regional Directors, Azure Insiders, Docker Insiders, ASP.NET Insiders, Web API Advisors, Cosmos DB Insiders as well as experts in other Microsoft and open-source technologies.
  • Top clients: We help Fortune 500, large and mid-size companies with ASP.NET Core and .NET upgrades, development, consulting, recruiting services and hands-on training services. Our clients include Thomson Reuters, Dell, Bank of America, Broadcom and Credit Suisse.

Over the years, different types of data models and structures came into existence and to satisfy the ever increasing demands in the industry. Many organizations came up with different solutions to solve data management problems. While polyglot persistence is the way to go for most modern applications, it’s not easy to create a mapper that works for all kinds of data stores. ORM (or Object relational mappers) were created to map relational databases with objects in an object oriented language like Java or C#. Relational databases are normalized and have tables and columns. Mapping relational data in terms of objects is not as intuitive as NoSQL databases. NoSQL databases have documents with properties, which can be easily represented in terms of objects. Even NoSQL databases are designed very differently. A caching engine like Memcached is just a key-value pair optimized for retrieval. Redis is similar but allows certain data structures on top of providing a key-value pair. A document database like Azure Cosmos DB, MongoDB or Cassandra is capable of a lot more functionality, almost as good as a relational database. A search engine like Solr or Elasticsearch is capable of efficiently indexing searchable data to create a great information retrieval user experience.

It’s a daunting task to maintain the breadth of support EF core has and improve the performance with every major release. However, Microsoft has made it possible with a performance-first architecture. Even though EF Core supports multiple databases, they are entirely standalone packages. In the past, many ORMs have made the mistake of only creating one package to support multiple databases. This leads to all sorts of issues including performance as well as delayed upgrades. There are hundreds of ORM libraries available today in the industry. However, there are very few that are open source, easy to use, offer such breadth of support, provide Microsoft LTS (Long Term Support) and offer high performance. EF Core happens to be a rare gem.

What is EF Core?

Entity Framework (EF) Core is a lightweight, extensible, open source and cross-platform version of the popular Entity Framework data access technology. It is an ORM that reduces the need to write most of the data-access code and enables developers to work with domain objects instead of datatables and property bags. The DbContext object that acts as a bridge between the .NET (domain) objects and the database. It is the primary class that is responsible for interacting with the database. Some of the features provided by DbContext includes querying, change tracking, transactions, object materialization, managing relationships, caching and more.

EF Core Code First
Figure1: Code-first approach (Developers write code and tables are generated automatically)

EF Core uses the Language-Integrated Query (LINQ) to query data from the database that enables writing strongly typed queries with the language of our choice. It passes a representation of the LINQ query to the database provider, which in turn translates it to database-specific query language. EF Core allows fluently configuring entity relationships and handles optimistic concurrency and these APIs are available across multiple database backends.

EF Core promotes developers to use industry standard design patterns and principles for developing world-class applications. It supports polyglot persistence and works really well with a number of databases using pluggable libraries called database providers. It offers seamless support for SQL Server, Sqlite, Postgres, Oracle, MySQL, DB2, Informix, Cosmos DB, MongoDB, Cassandra, Teradata, Google Cloud Spanner, Progress OpenEdge, Microsoft Access and many other databases. It can also be used to manage data stored in files or in-memory. Being open source, many private companies and the community continue to create new libraries for EF Core.

EF Core Database Providers

Main Features

EF Core is being built in increments and every new version offers new features and improvements. Although it is difficult to include every feature in this article we have created a list of the most important and common features that EF Core has to offer.

  • Entity relationships: Tables in a relational database can be related through different kinds of relationships. EF Core offers support for one-to-one, one-to-many and many-to-many relationships. There are two ways to configure domain classes in EF Core - by using Data Annotation Attributes and/or using Fluent API. It also provides mapping between documents in a NoSQL database and objects in C#.
  • Transactions: In the database world, transactions allow several database operations to be processed in an atomic manner. It is an approach that guarantees all or none commitment. A transaction guarantees that all the operations have been successfully committed to the database. In case any of the operations fail, the transaction guarantees a successful rollback to the state of the database before the transaction was attempted . This helps keep the data consistent and avoid any erroneous state.

    EF Core offers support for atomic transactions. It offers a single command to aggregate different related objects into a single complex object graph and save them to the database. That command internally creates a transaction and applies all changes to the database in a single call. EF Core also allows manually managing transactions, although it must be used only if it is necessary.
  • Change tracking: The ChangeTracker class tracks the current state of every entity retrieved using the same DbContext instance. Entities are tracked as soon as they are retrieved using DbContext until they go out of its scope. The ChangeTracker tracks the changes applied to all the entities and their properties and later uses it to build and execute appropriate DML statements to the underlying data source. This deferred execution reduces unnecessary calls to the database. The well defined API also benefits from performance enhancements in the newer versions of EF Core. Code once and optimize with every upgrade has been one reason that EF Core is loved by developers.
  • Security: EF Core also offers support for executing raw SQL queries and stored procedures in case LINQ offers inefficient query performance. It also offers functions like FromSqlInterpolated and ExecuteSqlInterpolated that enables developers to use string interpolation syntax in a way that protects against SQL injection attacks.
  • Logging: Logging allows you to track SQL and changes in the state of the entity for debugging purposes. EF Core integrates with the .NET Core logging to log information to the various output targets.
  • Database upgrade: Imagine moving from SQL Server on Windows to PostGres on Linux, or to Cosmos DB. The change becomes a simple configuration issue if the data layer is written using EF Core. This ease of portability makes a great use case for developers to use EF Core. This also reduces the amount of work required to learn new databases.
  • Productivity: The simplicity of the API helps increase productivity. Speed of development is increased by reducing the complexity pertaining to database connectivity and transaction processing and enables developers to focus on the business logic.
  • EF Core 5.0: Support for this version ends in mid May 2022. This version offered support for many-to-many relationships without explicitly mapping the join table, split queries, simple logging and improved diagnostics, flexible entity mapping, database collations, event counters and more.
  • EF Core 3.1: This version has a long term support, which ends on December 3, 2022. It offered support for C# 8 and enabled developers to take advantage of its latest features. Support for Cosmos DB was also added. Other features include support for asynchronous streams, nullable reference types, interception of database operations, reverse engineering of database views and more.

EF Core 6

EF Core 6 Performance
  • High performance: Traditionally, Cazton has helped use ORMs like Dapper, NHibernate, EF and EF Core. Many companies choose Dapper over EF Core. That’s because it is a popular, lightweight and a performance-oriented .NET object mapper. It is often referred to as a micro-ORM because it does not offer many features of EF Core. But now with the latest performance improvements in EF Core 6, the performance results have been narrowed down from 55% to under 5% for certain benchmarks.

    EF Core on .NET 6 offers massive performance improvements and executes queries 92% faster than on .NET 5. It is 31% faster in executing untracked queries and offers 43% reduction in heap allocation when executing queries.
  • Compiled models: For applications that have more than hundreds or thousands of large models representing tables in the database, the application may take some extra time to (startup) load and perform the first operation on a DbContext. The new compiled model capability addresses this problem and reduces the startup time. EF Core 6 offers a simple command that can be run statically during development and generate the compiled model. We can then introspect that model and use it in our application to improve the startup time.
  • Pre-convention model configuration: At times, there are properties in the entities that require different configuration over the default settings. For example, a string that needs a max length restriction or decimals that require a different precision. With the previous versions of EF Core, we would typically do this by explicitly assigning the attribute on every single property or via the model builder configuration for each property.

    With EF Core 6, we can now configure settings once for a given data type. It will then be applied to all properties of that type in the model. This is called pre-convention model configuration.
  • Migration bundles: One of the greatest features of EF Core is to update the schema of the database with simple migration commands. These schema updates would be a part of the CI/CD system and be applied during deployment time. EF Core 6 offers a new way to apply these schema updates using what is called the migration bundles.

    Migration bundles are small platform specific executables that contain the migrations and the schema changes needed to be applied to the database. So in our application we can create multiple migrations and can bundle them together into a single executable. This feature greatly simplifies the migration process.
  • Temporal tables: This is basically a feature of SQL Server that keeps track of every change we make to the database. So any operation such as updating or deleting a record would make SQL Server take a snapshot of that data before performing the operation and store it in a separate table called the history table. This table can later be used in auditing or recovering the data that got deleted unintentionally.

    EF Core 6 provides the ability to create these temporal tables by configuring our entities with the model builder. It also offers new LINQ operators that can be used for querying and restoring historical data.
  • LINQ query enhancements: There are quite a few improvements in the translation and execution of LINQ queries including:
    • Improved support for GroupBy clause with a bunch of new capabilities.
    • Calls to String.Concat with multiple arguments are now translated to SQL.
    • More flexible SQL Server free-text search.
    • Improved SQL Server translation for IsNullOrWhitespace.
    • Defining query against the in-memory database for a given entity type.
    • Split-queries for non-navigation collections and much more.

There are many more exciting features and improvements that EF Core 6 has to offer. Contact us to learn more.

Highlights of our Microsoft Practice

  • Our team has great expertise in building multi-million-dollar enterprise web applications (with billions in revenue per year) for our Fortune 500 clients.
  • We have expertise in many different domains: healthcare, insurance, finance, tech, entertainment, retail, energy, just to name a few.
  • We have been fortunate to work directly with Microsoft product teams for almost a decade.
  • Our team includes Microsoft awarded Most Valuable Professionals, Azure Insiders, Docker Insiders, ASP.NET Insiders, Web API Advisors, Cosmos DB Insiders as well as experts in other Microsoft as well as open-source technologies.
  • We help our clients with:
    • Software Development
    • Upgrades to latest versions
    • DevOps and Automation
    • Consulting and Mentoring
    • Training and Recruiting

Cazton success stories

With the frequent changes in operating systems, platforms, frameworks and browsers, developers have a lot to keep up with these days. They can’t specialize and be experts in every technology they work on. With an expert-led team like ours, we bring the benefit of our network to you. We save our clients a serious amount of effort on tasks they shouldn’t be doing by providing them a streamlined strategy and updating it as and when we get more information. We work with Fortune 500, large and mid-size corporations and we learn what works and what doesn’t work and incorporate that in our feedback to our clients to make sure their projects are successful.

How can Cazton help you with EF Core?

At Cazton, we help Fortune 500, large and mid-size companies with .NET development, consulting, recruiting services and hands-on training services. Our team includes Microsoft Regional Directors, Microsoft awarded Most Valuable Professionals, Azure Insiders, Docker Insiders, ASP.NET Insiders, Web API Advisors, Cosmos DB Insiders as well as experts in other Microsoft and notable open-source technologies.

We have significant experience in Microsoft technology stack, and our expertise can enhance your project’s performance and improve its efficiency. Our experts have in-depth knowledge and experience with the underlying database server and can help you architect, develop and profile high performance production apps. We believe in customising each solution to tailor to the exact needs of the client. We can provide you the following services:

  • Customized solutions with EF Core support built for the web, cloud, desktop and mobile.
  • EF Core Consulting.
  • Customized EF Core Training.
  • Migrate your existing code from Entity Framework to EF Core.
  • Troubleshooting and optimizing performance of your existing application.
  • Consult you with Database and EF Core design and architectural best practices.
  • Consult you with security best practices.
  • Perform functional, integration, performance and stress testing.
  • Setup logging and diagnostics for in depth application insights.
  • Setup a scale-out architecture (using cloud, on-prem and container based technologies).
  • Improve database performance.
  • Help with data recovery, hardware and database upgrades.
  • Migrate your on-prem databases to the cloud.
  • Perform code reviews.
  • Custom development, consulting and training services for Web, mobile, desktop and hybrid applications, gRPC, Apis, SignalR, front-end and back-end solutions, big data, machine learning and artificial intelligence. We support the entire .NET ecosystem including .NET 5, .NET 6, ASP.NET Core and all versions of classic .NET framework. We work on a wide array of technologies including: Blazor, Angular, React, Vue, TypeScript, EF Core, MAUI, Xamarin and support all major RDBMSs (SQL Server, Postgres, MySQL, Oracle) and NoSQL databases (Azure Cosmos DB, MongoDB, Cassandra, Riak, Redis, Elastic search, Solr etc.)

Our clients trust us to deliver complicated projects within a short delivery time frame. We have saved our clients millions of dollars and have proven multiple times that we can be more economical than even offshore options. We can provide our experts with flexible engagements at a very cost-effective rate.

Cazton is composed of technical professionals with expertise gained all over the world and in all fields of the tech industry and we put this expertise to work for you. We serve all industries, including banking, finance, legal services, life sciences & healthcare, technology, media, and the public sector. Check out some of our services:

Cazton has expanded into a global company, servicing clients not only across the United States, but in Oslo, Norway; Stockholm, Sweden; London, England; Berlin, Germany; Frankfurt, Germany; Paris, France; Amsterdam, Netherlands; Brussels, Belgium; Rome, Italy; Sydney, Melbourne, Australia; Quebec City, Toronto Vancouver, Montreal, Ottawa, Calgary, Edmonton, Victoria, and Winnipeg as well. In the United States, we provide our consulting and training services across various cities like Austin, Dallas, Houston, New York, New Jersey, Irvine, Los Angeles, Denver, Boulder, Charlotte, Atlanta, Orlando, Miami, San Antonio, San Diego, San Francisco, San Jose, Stamford and others. Contact us today to learn more about what our experts can do for you.

Copyright © 2022 Cazton. • All Rights Reserved • View Sitemap