Entity Framework Code First DataAnnotations [Table] attribute

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

[Table("People")]
public class Person
{
    public int PersonID { get; set; }
    public string PersonName { get; set; }    
}

Tells Entity Framework to use a specific table name instead of generating one (i.e. Person or Persons)

We can also specify a schema for the table using [Table] attribute

[Table("People", Schema = "domain")]


Got any Entity Framework Question?