LinqConnect Documentation
In This Topic
    PrimaryKeyConfiguration Class
    In This Topic
    PrimaryKeyConfiguration Class
    LinqConnect Documentation
    PrimaryKeyConfiguration Class
    [email protected]

    PrimaryKeyConfiguration class is used to define mapping configuration for primary key.

    The list of the primary key properties is defined with the PrimaryKey method of the EntityConfiguration class. This method returns a PrimaryKeyConfiguration instance. Currently this class has only one public method - DbGenerated(), which sets IsDbGenerated = true and AutoSync = AutoSync.OnInsert for primary key properties to make them be updated from the database after insert.

    builder.Entity<Company>()
        .PrimaryKey(company => company.Id)
            .DbGenerated();
     
    builder.Entity<OrderDetail>()
        .PrimaryKey(orderDetail => new { orderDetail.OrderID, orderDetail.ProductID })
            .DbGenerated();