Download presentation
Presentation is loading. Please wait.
Published byGriffin Hoover Modified over 9 years ago
1
OVERVIEW ON HOW ENTITY FRAMEWORK CODE FIRST CAN EASE THE DEVELOPMENT PROCESS Entity Framework Code First 11/19/2013 Joe Walling Copyright Walling Info Systems
2
What is Code First You focus on domain design, creating classes that match your database and the code first apis create the db on the fly. Basic workflow Create code first classes F5 Database auto created Default data added (if specified) Launch application 11/19/2013 Joe Walling Copyright Walling Info Systems
3
Convention Based Persistence Mapping 11/19/2013 Joe Walling Copyright Walling Info Systems No tools or XML mapping files are required to create mappings between model and database This is because of convention over configuration You can override default behavior but the default requires little to work Pluralize entity name for table name Properties map to columns in table Id or tablenameid maps to primary key Show simple example
4
DB Initialization How it works Strategies CreateDatabaseIfNotExists DropCreateDatabaseIfModelChanges DropCreateDatabaseAlways Custom Where to set Code Config Turning off DbInitializer Show examples 11/19/2013 Joe Walling Copyright Walling Info Systems
5
Configure Domain Classes Create data model Create data context Customize using Data annotations Fluent API 11/19/2013 Joe Walling Copyright Walling Info Systems
6
Migrations Automated – run Nuget package manager Code based Add-migration Update-database Show migration file and history Rollback and when needed When each is used Implications on group development 11/19/2013 Joe Walling Copyright Walling Info Systems
7
Configure Relationship One to one One to many Many to may 11/19/2013 Joe Walling Copyright Walling Info Systems
8
Annotations Validation Attributes Required MinLength MaxLength StringLength Database Schema Related Table Column Key Timestamp ForeignKey NotMapped DatabaseGenerated Inverse property ConcurrencyCheck 11/19/2013 Joe Walling Copyright Walling Info Systems
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.