I'm using EF4 with CodeFirst
public class People : DbContext
{
public DbSet<Human> Humans { get; set; }
public DbSet<Child> Children { get; set; }
}
At the moment, EF looks in the database for the Human
table. How can I specify for it to look for Humans
instead?
The Column attribute can be applied to one or more properties in an entity class to configure the corresponding column name, data type and order in a database table.
You can change table name on Human
class:
[Table("Humans")]
public class Human
{
...
}
Other way is to use Fluent API:
modelBuilder.Entity<Human>()
.ToTable("Humans");
Similary you can use ColumnAttribute
or HasColumnName
method to change the name of column.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With