Поддержка  •  Дневник  •  Без рекламы  •  О сайте  •  Реклама  •  Поставить баннер  •  Fleshlight  •  Прислать  •  Хроника  •  Translate Гости: 2    Участники: 0 Авторизация Авторизация   Регистрация 
Метод Научного Тыка
RULVEN
Поиск  
Blackball iMag | интернет-журнал
Каталог


Начало » Разработка ПО » Top 9 Entity Framework Core features in 2023 you can’t miss
Мне повезёт!

Top 9 Entity Framework Core features in 2023 you can’t miss


Добавлено: Ср 17.01.2024 • Sergeant
Автор: Alex Maher
Просмотров: 29
Комментарии: 0


Entity Framework Core features in 2023

Entity Framework Core

EF Core 2023 has rolled out some pretty cool stuff, and I’m excited to share it with you. So, grab a cup of coffee, and let’s get started!

1. Cosmos DB Provider Improvements

Azure Cosmos DB and EF Core are like two peas in a pod, but with EF Core 8.0, they’re even cozier. Enhanced support means tighter integration and smoother operations.

Code Example:

var cosmosOptionsBuilder = new DbContextOptionsBuilder<MyContext>()
    .UseCosmos("https://mycosmosaccount.documents.azure.com:443/", "myPrimaryKey", "myDatabaseName");

This is a significant leap for cloud developers. The tighter integration reduces boilerplate code, making our cloud-based apps more efficient and maintainable.

2. Temporal Tables

Time-travel isn’t just for sci-fi movies. With SQL Server temporal tables support, EF Core 8.0 lets us revisit our data’s past states.

Code Example:

modelBuilder.Entity<Order>().ToTable("Orders", t => t.IsTemporal());

This feature is a lifesaver for debugging and auditing. Being able to track data changes directly from EF Core simplifies many tasks that previously required complex solutions.

3. Table-per-Type (TPT) Mapping

Data modeling debates have a new contender. TPT mapping in EF Core 8.0 offers a fresh approach to organizing our data, especially when inheritance is in play.

Code Example:

modelBuilder.Entity<Contractor>().ToTable("Contractors");
modelBuilder.Entity<Employee>().ToTable("Employees");

For projects where data separation is crucial, TPT is a breath of fresh air. It provides clarity in the database schema, making it easier to manage and understand.

4. Migrations Bundles

Deployment headaches, be gone! Migrations Bundles in EF Core 8.0 encapsulate all migration-related elements, streamlining the deployment process.

Code Example:

var bundle = context.Database.CreateMigrationBundle();
File.WriteAllBytes("MigrationsBundle.zip", bundle);

This is a game-changer for CI/CD pipelines. Simplifying migrations means fewer deployment issues and faster release cycles.

5. Compiled Models

Speed is the name of the game. With Compiled Models, EF Core 8.0 boosts startup performance, especially for models with a large number of entities.

Code Example:

var options = new DbContextOptionsBuilder<MyContext>()
    .UseModel(CompiledModel.Default)
    .Options;

In today’s fast-paced world, every millisecond counts. Improving startup times enhances user experience, especially in microservices architectures.

6. HierarchyID Mapping

Organizing data in a hierarchical manner has always been a challenge. With the introduction of hierarchyid type support in EF Core 8.0, representing data like organizational charts or file systems becomes more intuitive.

Code Example:

modelBuilder.Entity<Organization>().Property(e => e.HierarchyId).HasConversion<string>();

This feature simplifies the representation of tree structures in our databases. It’s a step forward in making complex data structures more manageable and queryable.

7. Raw SQL Queries for Unmapped Types

Sometimes, ORM can feel restrictive, especially when we need to execute raw SQL. EF Core 8.0 expands its raw SQL capabilities, allowing us to return any mappable CLR type, even if it’s not part of our EF model.

Code Example:

var blogs = context.Set<Blog>().FromSqlRaw("SELECT * FROM dbo.Blogs").ToList();

This feature provides the flexibility many developers crave. It bridges the gap between raw SQL and ORM, offering the best of both worlds.

8. Updating Hierarchies

Hierarchical data structures are common, but updating them? That’s a different ball game. EF Core 8.0 introduces mechanisms to update hierarchyid columns seamlessly, making changes to hierarchical data structures a breeze.

Code Example:

var node = new HierarchyNode("/1/3/");
node = node.GetReparentedValue(oldRoot: new HierarchyNode("/1/"), newRoot: new HierarchyNode("/2/"));

This feature is a testament to EF Core’s commitment to simplifying complex operations. Being able to reparent a node or a sub-hierarchy without manual SQL scripting is a huge time-saver.

9. Configuration of and Complex Types

With flexibility at its core, EF Core 8.0 offers multiple ways to configure complex types. Whether you prefer mapping attributes or love diving deep into the OnModelCreating method, EF Core has got you covered.

Code Example:

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<Customer>()
        .ComplexProperty(e => e.Address);
}

The flexibility in configuration ensures that developers can mold the framework to their preferred coding style, making it adaptable to various project structures.

Complex Types for Value Objects

In the past, handling objects that held multiple values but lacked a unique identifier was a challenge. Now, objects like Address can be used across different entities without needing a separate table. This not only streamlines our database schema but also brings our models closer to the domain-driven design principles.

Code Example:

[ComplexType]
public class Address
{
    public required string Line1 { get; set; }
    public string? Line2 { get; set; }
    public required string City { get; set; }
    public required string Country { get; set; }
    public required string PostCode { get; set; }
}

This feature simplifies the representation of value objects, making our code cleaner and more maintainable.



Мне нравится 0   Мне не нравится 0



Комментарии

Чтобы добавить видео с YouTube, нужно написать [@youtube=xxxxx] , где xxxxx – ID видео.


Комментарии: 0
Нет ни одного комментария.
RSS-лента
Поделиться ссылкой:
Запускаем приложения Android на компьютере с Windows Запускаем приложения Android на компьютере с Windows
25 самых дорогих видов шоколада в мире 25 самых дорогих видов шоколада в мире
20 отличных рецептов куриных сердечек на мангале 20 отличных рецептов куриных сердечек на мангале
Настойка и наливка: в чём разница Настойка и наливка: в чём разница
Коктейль виски со Швепсом – оригинальные и согревающие рецепты Коктейль виски со Швепсом – оригинальные и согревающие рецепты
Буженина из свинины в домашних условиях: 12 пошаговых рецептов Буженина из свинины в домашних условиях: 12 пошаговых рецептов
Какие полочные акустические системы стоит выбрать в 2023-2024 годах? Какие полочные акустические системы стоит выбрать в 2023-2024 годах?
Лосось в духовке - лучшие рецепты запечённого в духовке лосося Лосось в духовке - лучшие рецепты запечённого в духовке лосося
Жизнь в 100 словах
8 лучших рецептов мегрельского соуса 8 лучших рецептов мегрельского соуса

database
Ср 03.04.2024
Visual representation of SQL joins
Ср 17.01.2024
Top 9 Entity Framework Core features in 2023 you can’t miss
Practical Azure SQL Database for Modern Developers Вт 09.01.2024
Practical Azure SQL Database for Modern Developers
Год: 2021
The Definitive Guide to SQLite, Second Edition Чт 24.03.2022
The Definitive Guide to SQLite, Second Edition
Год: 2010
PostgreSQL Server Programming, Second Edition Вт 15.03.2022
PostgreSQL Server Programming, Second Edition
Год: 2015
Troubleshooting PostgreSQL Чт 03.03.2022
Troubleshooting PostgreSQL
Год: 2015
PostgreSQL Developer's Guide Вт 01.03.2022
PostgreSQL Developer's Guide
Год: 2015
Работа с PostgreSQL, настройка и масштабирование Чт 24.02.2022
Работа с PostgreSQL, настройка и масштабирование
Год: 2014
PostgreSQL Cookbook Вт 22.02.2022
PostgreSQL Cookbook
Год: 2015
PostgreSQL Administration Cookbook, 9.5/9.6 Edition Чт 17.02.2022
PostgreSQL Administration Cookbook, 9.5/9.6 Edition
Год: 2017
Practical MongoDB: Architecting, Developing, and Administering MongoDB Вт 15.02.2022
Practical MongoDB: Architecting, Developing, and Administering MongoDB
Год: 2015
MongoDB in Action Чт 10.02.2022
MongoDB in Action
Год: 2011
PostgreSQL High Availability Cookbook, Second Edition Чт 30.12.2021
PostgreSQL High Availability Cookbook, Second Edition
Год: 2017
NHibernate 4.0 Cookbook Вт 26.10.2021
NHibernate 4.0 Cookbook
Год: 2017
Pro SQL Server 2008 Policy-Based Management Чт 04.03.2021
Pro SQL Server 2008 Policy-Based Management
Год: 2010
The Definitive Guide to SQLite, 2nd Edition Вт 02.03.2021
The Definitive Guide to SQLite, 2nd Edition
Год: 2006
Пн 09.03.2020
14 вопросов об индексах в SQL Server, которые вы стеснялись задать
PostgreSQL 9.0 High Performance Вт 24.12.2019
PostgreSQL 9.0 High Performance
Год: 2010
MongoDB Cookbook, 2nd Edition Вт 03.12.2019
MongoDB Cookbook, 2nd Edition
Год: 2016
Пн 29.07.2019
Dapper - King of Micro ORM (C#.NET)
Семь баз данных за семь недель. Введение в современные базы данных и идеологию NoSQL Вт 06.11.2018
Семь баз данных за семь недель. Введение в современные базы данных и идеологию NoSQL
Год: 2013
Next Generation Databases: NoSQL, NewSQL, and Big Data Вт 30.10.2018
Next Generation Databases: NoSQL, NewSQL, and Big Data
Год: 2015
Книги
Designing Data-Intensive Applications Вт 14.05.2024
Designing Data-Intensive Applications
Год: 2017
Fundamentals of Software Architecture Вт 07.05.2024
Fundamentals of Software Architecture
Год: 2020
Refactoring with C# Вт 23.04.2024
Refactoring with C#
Год: 2023

Разработано на основе BlackNight CMS
Release v.2024-05-18
© 2000–2024 Blackball
Дизайн & программирование:
О сайтеРеклама
Visitors
Web-site performed by Sergey Drozdov
BlackballРекламаСтатистикаПоддержка | МузыкаПлейлистыКиноВидеоИгрыАудиоПрограммыСтатьиКартинкиЮморФорумДневник сайтаПрислать контент