-
Notifications
You must be signed in to change notification settings - Fork 2
Model Building
Todd Thomson edited this page Aug 17, 2018
·
10 revisions
Database entity models are built using a fluent API for mapping POCO objects to database tables. Within your DataContext, override the OnModelBuilding() method.
Entities.Sqlite provides the following mapping builders to build your entity model. Follow each link to see complete details of each mapping.
Entities.Sqlite provides entity auto mapping by conventions for table naming and setting a primary key.
For each entity within your data context specify your mapping with the following code.
protected override void OnModelBuilding( RelationalModelBuilder modelBuilder )
{
modelBuilder.Entity<TodoItem>( entity =>
{
// Additional entity mapping goes here
} );
}
Use .ToTable( string tableName ) to set your table name.
Entities.Sqlite supports 1-1 and 1-many relationships.