Manoj Kumar Mahato
Manojmahato.com.np
Entity Framework
 developers used to write code manually to fetch data
and convert the data to domain object and then pass
the object across layers.
 automate the mapping process by some framework
which will be able to create class automatically from
the database, or will be able to replicate the table as a
class.
Three approaches to implement
Entity Framework
 Code First Approach
 Database First
 Model First
Database First
 database already exists
 database structure is very complex and need to involve
DBA professional.
 work both coding and DB part of application.
 it’s not directly dependent on code.
 Change database, update model, works smoothly.
Model First
 less popular compared to code first and database first
 create data mode at first.
 share with other non-technical people.
Code First Approach
 write code at first to generate database
 hard code developer, always like to kid with code.
 application is new and is there is no existing database.
What we do today?
 basics of code-first
 configure one-to-one, one-to-many and many-to-
many relationships
 DataAnnotation, as well as Fluent API.
DEMO
CRUD Operation
Questions ?
Thank You

Code first approach in entity framework

  • 1.
  • 2.
    Entity Framework  developersused to write code manually to fetch data and convert the data to domain object and then pass the object across layers.  automate the mapping process by some framework which will be able to create class automatically from the database, or will be able to replicate the table as a class.
  • 3.
    Three approaches toimplement Entity Framework  Code First Approach  Database First  Model First
  • 4.
    Database First  databasealready exists  database structure is very complex and need to involve DBA professional.  work both coding and DB part of application.  it’s not directly dependent on code.  Change database, update model, works smoothly.
  • 5.
    Model First  lesspopular compared to code first and database first  create data mode at first.  share with other non-technical people.
  • 6.
    Code First Approach write code at first to generate database  hard code developer, always like to kid with code.  application is new and is there is no existing database.
  • 7.
    What we dotoday?  basics of code-first  configure one-to-one, one-to-many and many-to- many relationships  DataAnnotation, as well as Fluent API.
  • 8.
  • 9.
  • 10.