Entity Framework Table Data Annotation
In EF 6, the default convention creates a table name matching with <DbSet<TEntity> property name + 's' or 'es' in a context class.
- The
Tableattribute overrides this default convention. - It is applied to an entity to specify the name of the database table that the entity should map to.
The following example specifies that the Book entity should map to a database table named BooksInfo.
[Table("BooksInfo")] public class Book { public int BookId { get; set; } public string Title { get; set; } }
If the table that the entity maps to belongs to a non-default schema, the Table attribute provides a way to specify the name of the schema through the Schema property.
[Table("BooksInfo", Schema="lib")] public class Book { public int BookId { get; set; } public string Title { get; set; } }
ZZZ Projects