concept one database access in category entity framework

appears as: one database access
Entity Framework Core in Action

This is an excerpt from Manning's book Entity Framework Core in Action.

  • The LINQ query db.Books.AsNoTracking().Include(a => a.Author) accesses the DbSet<Book> property in the application’s DbContext and adds a .Include(a => a.Author) at the end to ask that the Author parts of the relationship are loaded too. This is converted by the database provider into an SQL command to access the database. The resulting SQL is cached to avoid the cost of retranslation if the same database access is used again.

    EF Core tries to be as efficient as possible on database accesses. In this case, it combines the two tables it needs to read, Books and Author, into one big table so that it can do the job in one database access. The following listing shows the SQL created by EF Core and the database provider.

    Listing 1.3 SQL command produced to read Books and Author
    SELECT [b].[BookId], 
    [b].[AuthorId], 
    [b].[Description], 
    [b].[PublishedOn], 
    [b].[Title], 
    [a].[AuthorId], 
    [a].[Name], 
    [a].[WebUrl]
    FROM [Books] AS [b]
    INNER JOIN [Author] AS [a] ON 
    [b].[AuthorId] = [a].[AuthorId]
  • EF Core tries to be as efficient as possible on database accesses. In this case, it combines the two tables it needs to read, Books and Author, into one big table so that it can do the job in one database access. The following listing shows the SQL created by EF Core and the database provider.