Composing Entity Framework Fluent Configurations
Posted by: K. Scott Allen,
on 28 Nov 2011 |
View original | Bookmarked: 0 time(s)
The canonical example for fluent configuration with the Entity Framework is to take a few simple entity definitions: public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public byte[] Version { get; protected set; }
}
... and configure them all inside of the DbContext's OnModelCreating method:
protected override void OnModelCreating(
DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Product>().ToTable("products");
// ... more configuration
...