From 087b81c3aa5ffb012a318038c478713bb9e1751e Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 16 Nov 2023 10:11:15 +0800 Subject: [PATCH 1/2] Update Abp-8_0.md --- docs/en/Migration-Guides/Abp-8_0.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/en/Migration-Guides/Abp-8_0.md b/docs/en/Migration-Guides/Abp-8_0.md index b8db916e28..665768d3c4 100644 --- a/docs/en/Migration-Guides/Abp-8_0.md +++ b/docs/en/Migration-Guides/Abp-8_0.md @@ -103,6 +103,16 @@ You don't need to make any changes related to that, however it's important to kn In this version, `AbpAspNetCoreAsyncIntegratedTestBase` class has been set as `Obsolete` and it's recommended to use `AbpWebApplicationFactoryIntegratedTest` instead. +## Use NoTracking for readonly repositories for EF core. + +ABP Framework provides read-only [repository](Repositories.md) interfaces (`IReadOnlyRepository<...>` or `IReadOnlyBasicRepository<...>`) to explicitly indicate that your purpose is to query data, but not change it. If so, you can inject these interfaces into your services. + +Entity Framework Core read-only repository implementation uses [EF Core's No-Tracking feature](https://learn.microsoft.com/en-us/ef/core/querying/tracking#no-tracking-queries). That means the entities returned from the repository will not be tracked by the EF Core [change tracker](https://learn.microsoft.com/en-us/ef/core/change-tracking/), because it is expected that you won't update entities queried from a read-only repository. + +> This behavior works only if the repository object is injected with one of the read-only repository interfaces (`IReadOnlyRepository<...>` or `IReadOnlyBasicRepository<...>`). It won't work if you have injected a standard repository (e.g. `IRepository<...>`) then casted it to a read-only repository interface. + +> See the issue for more information: https://github.com/abpframework/abp/pull/17421 + ## Upgraded NuGet Dependencies You can see the following list of NuGet libraries that have been upgraded with .NET 8.0 upgrade, if you are using one of these packages explicitly, you may consider upgrading them in your solution: From c101ca45ca5700837e230f4886fdb9d438927bf1 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 16 Nov 2023 10:12:24 +0800 Subject: [PATCH 2/2] Update Abp-8_0.md --- docs/en/Migration-Guides/Abp-8_0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/Migration-Guides/Abp-8_0.md b/docs/en/Migration-Guides/Abp-8_0.md index 665768d3c4..a081332777 100644 --- a/docs/en/Migration-Guides/Abp-8_0.md +++ b/docs/en/Migration-Guides/Abp-8_0.md @@ -105,7 +105,7 @@ In this version, `AbpAspNetCoreAsyncIntegratedTestBase` class has been set as `O ## Use NoTracking for readonly repositories for EF core. -ABP Framework provides read-only [repository](Repositories.md) interfaces (`IReadOnlyRepository<...>` or `IReadOnlyBasicRepository<...>`) to explicitly indicate that your purpose is to query data, but not change it. If so, you can inject these interfaces into your services. +In this version, ABP Framework provides read-only [repository](Repositories.md) interfaces (`IReadOnlyRepository<...>` or `IReadOnlyBasicRepository<...>`) to explicitly indicate that your purpose is to query data, but not change it. If so, you can inject these interfaces into your services. Entity Framework Core read-only repository implementation uses [EF Core's No-Tracking feature](https://learn.microsoft.com/en-us/ef/core/querying/tracking#no-tracking-queries). That means the entities returned from the repository will not be tracked by the EF Core [change tracker](https://learn.microsoft.com/en-us/ef/core/change-tracking/), because it is expected that you won't update entities queried from a read-only repository.