Class Mapping
Attribute-based control over how a class and its properties line up with tables, columns, keys, and handlers.
Table and column names
The [Map] attribute (or the standard [Table]/[Column] attributes) renames a class or property to match a database object that doesn’t share its .NET name.
[Map("[sales].[Customer]")]
public class Customer
{
[Map("FName")]
public string FirstName { get; set; }
}
Primary and identity keys
[Primary] and [Identity] mark which property is the key and which one is server-generated — the standard [Key] attribute from System.ComponentModel.DataAnnotations works as a drop-in alternative for [Primary].
Handlers and database types
[ClassHandler], [PropertyHandler], and [TypeMap] round out class mapping by attaching conversion logic and explicit database types at the class or property level. See Type Mapping for the type-level details.