concept key in category entity framework

appears as: key, keys, keys, The key, key
Entity Framework Core in Action

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

Listing 3.15 The Review class, showing the foreign key back to the Book entity class
public class Review    #1  
{
    public int ReviewId { get; set; }
    public string VoterName { get; set; }
    public int NumStars { get; set; }
    public string Comment { get; set; }

    //-----------------------------------------
    //Relationships
    public int BookId { get; set; }    #2  
}

#1   Holds customer reviews with their ratings
#2   Foreign key holds the key of the book this review belongs to

Figure 9.4 Updating an entity with both a Db generated key and not default value and a Not Db generated key, or key is default value relationship. The “Db generated key and not default value” case is shown in step 2. The “Not Db generated key, or key is default value” case is shown in step 3.

c09_04.png
Listing 14.4 The RavenUpdater class that handles the read-side database updates
public class RavenUpdater : INoSqlUpdater    #1  
{
    private readonly DocumentStore _store;    #2  
    private readonly ILogger _logger;    #3  
    public RavenUpdater(DocumentStore store,    #4  
        ILogger logger)    #4  
    {    #4  
        _store = store;    #4  
        _logger = logger;    #4  
    }    #4  
    public void DeleteBook(int bookId)    #5  
    {
        using(new LogRavenCommand    #6  
            ($"Delete: bookId {bookId}", _logger))    #6  
        using (var session = _store.OpenSession())    #7  
        {      
            session.Delete(    #8  
                 BookListNoSql    #9  
                     .ConvertIdToNoSqlId(bookId));    #9  
        }                                          
    }
    public void CreateNewBook(BookListNoSql book)    #10  
    {
        using (new LogRavenCommand    #6  
            ($"Create: bookId {book.GetIdAsInt()}",    #6  
                 _logger))    #6  
        using (var bulkInsert = _store.BulkInsert())  #11  
        {    #11  
            bulkInsert.Store(book);    #11  
        }    #11  
    }
//The UpdateBook and BulkLoad methods are left out to save space

#1   The RavenUpdater must implement the INoSqlUpdater interface so that the DataLayer can access it.
#2   The RavenDB’s link to the database, which is needed for every command
#3   You use this to log all the RavenDB accesses so you get a similar level of logging to what EF Core provides.
#4   The RavenUpdater is created by the RavenStore’s CreateNoSqlUpdater method. You do this so it can access the private IDocumentStore.
#5   Deletes a book list view from the RavenDB database
#6   LogRavenCommand will time how long the command takes (via the disposal of this method) and then log the message and time.
#7   A RavenDB command that provides a session. Sessions allow normal Create, Read, Write, and Update commands.
#8   Deletes the book from the RavenDB database
#9   The format of the RavenDB key is a string, which has to have a specific format to allow sorting on the key, so you have a specific method to convert the int to that format.
#10   Creates a new book list entry in the RavenDB database
#11   For this command, Oren Eini suggested using the BulkInsert, as it’s slightly quicker.