EF Core always applies configured cascading behaviors to tracked entities. This means that if the application loads all relevant dependent/child entities into the DbContext, as is shown in the examples above, then cascading behaviors will be correctly applied regardless of how the database is config...
在EF Core 3.0 之前,每次出現具有給定類型與識別碼的實體時,皆會使用相同的實體執行個體。 如此符合追蹤查詢的行為。 例如,這個查詢:C# 複製 var results = context.Products.Include(e => e.Category).AsNoTracking().ToList(); 會為每個與給定類別相關聯的 Product,傳回相同的 Category 執行個體。
在3.0 之前,通过 Include 运算符预先加载集合导航会导致在关系数据库上生成多个查询,每个相关实体类型对应一个查询。新行为从3.0 开始,EF Core 会在关系数据库上使用 JOIN 生成单个查询。原因以发出多个查询的方式实现单个 LINQ 查询会导致出现许多问题,包括由于需要执行多次数据库往返而引起的性能不佳问题,以及每个...
EF Core 我们使用 EF Core 来演示解释查询。 现在让我们来看看这项技术的主要特点。 EF Core Entity Classes EF Core 允许您使用任何类来表示数据,只要它包含您要查询的每个列的公共属性即可。 例如,我们可以定义以下实体类来查询和更新数据库中的 Customers 表: public class Customer { public int ID { get;...
基於這個理由,EF Core 6.0 現在會在儲存選擇性相依專案時發出警告,其中所有屬性都是 Null。 例如:warn: 9/27/2021 09:25:01.338 RelationalEventId.OptionalDependentWithAllNullPropertiesWarning[20704] (Microsoft.EntityFrameworkCore.Update) 類型為 'Address' 的實體,其主鍵值 {CustomerId: -2147482646} 是選擇...
Now with EF Core, this pair of classes—Samurai and Entrance (the character’s first appearance in the movie)—will be correctly identified as a uni-directional one-to-one relationship, with Entrance being the dependent type. I don’t need to include a navigation property in the Entrance and...
t have primary keys. EF has always been reliant on keys, so this is a big step for EF Core. Additionally, the query type will help you avoid any interaction with the change tracker, so you don’t have to add in code to protect your application from inadvertent runtime exceptions ...
TIP EF Core has always supported querying via stored procedures. The new support in EF7 is specifically about using stored procedures for inserts, updates, and deletes. Stored procedures are mapped in OnModelCreating using InsertUsingStoredProcedure, UpdateUsingStoredProcedure, and DeleteUsingStoredProced...
Entity Framework Core (EF Core) 是 .NET 平台流行的对象关系映射(ORM)框架。虽然 .NET 平台中 ORM 框架有很多,比如 Dapper、NHibernate、PetaPoco 等,并且 EF Core 的性能也不是最优的(这是由于 EF 的实体跟踪特性,将其禁用后可以大幅提升性能),但依然吸引到很多后端开发者的使用,原因如下: EF Core 由 ...
TIP EF Core has always supported querying via stored procedures. The new support in EF7 is specifically about using stored procedures for inserts, updates, and deletes. Stored procedures are mapped in OnModelCreating using InsertUsingStoredProcedure, UpdateUsingStoredProcedure, and DeleteUsingStoredProced...