How to specify the name of the table to be used by DbContext How to specify the name of the table to be used by DbContext asp.net asp.net

How to specify the name of the table to be used by DbContext


You can do the following on the entity:

[Table("Portfolio")]public class Product { /* ... */ }

By convention the table is named after the plural of the entities name.
So a DbSet<Product> will by default be stored / looked up in a table named Products.


Take a look at System.ComponentModel.DataAnnotations.Schema.TableAttribute.

Specifically:

[Table("Portfolio")]class Product{    public string Foo{get;set;}}