Entity Framework - how to specify the table name for an entity class manually

Posted on June 28, 2012 by Michael Roma

Below is the syntax used to specify what the exact table and schema is for an entity class defined in your project. In the example below, accountbase is the database table name, Account is the name of the EF class.

[Table("accountbase", Schema = "dbo")]
public class Account
{
    [Key]
    public int id { get; set; }

    public string Email { get; set; }
}
comments powered by Disqus