An entity is a C# class that EF Core maps to a database table, and each instance of it is one row in that table.
public class Product
{
public int Id { get; set; } // Primary key
public string Name { get; set; }
public decimal Price { get; set; }
public int CategoryId { get; set; }
// Navigation property
public Category Category { get; set; }
}
By convention, a property named Id or <TypeName>Id becomes the primary key. The other properties map to columns, and Category is a navigation property that points to a related entity.
An entity must be a class, not a struct, and it should have a key. EF Core does not need a parameterless constructor, because it can call a constructor whose parameters match mapped properties. It also maps properties with private setters.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
The diagram below the answer is the concept . Jump to it ↓