SlideShare a Scribd company logo
EF Code First Model ,[object Object],[object Object],[object Object],[object Object],Dmytryi  Lebedinskyi
Code First Model 1. Define Simple Entities with connection by ID
2.  Add virtual properties for lazy loading of Aggregated Fields EF lazy loading is enabled by default Code First Model
3.  Remember to preserve name convention  EF Code First uses general agreement about names.  Code First Model
4.  Create Data Context DbContext is similar to EF general Data Context Code First Model
Code First Model 5.  Create a Repositories
6.  What about usage?  You can work with it same like a general EF Model Code First Model
7. And what is the result? Code First Model
Code First Model 9.  Where is Database?  Default  DB Server is .qlExpress
Code First Model 10.  Change Database name  ,[object Object],[object Object],[object Object],[object Object]
EF Code First Model ,[object Object],[object Object],[object Object],[object Object]
Code First Model Database Initializers System.Data.Entity.Database .IDatabaseInitializer <in TContext> CreateDatabaseIfNotExists DropCreateDatabaseIfModelChanges DropCreateDatabaseAlways
Code First Model 1. Create  Initializer
Code First Model 2 .  Register Initializer
Code First Model 3 .  And we have data if no db is created
EF Code First Model ,[object Object],[object Object],[object Object],[object Object]
Since EF Code First  CTP5 Data Annotations can be used for DB structure Code First Model ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
And Validation Attributes are now also supported Code First Model
And using  some MVC Magic we receive  Code First Model
Questions? :)

More Related Content

What's hot

Dtd
DtdDtd
uptu web technology unit 2 Xml2
uptu web technology unit 2 Xml2uptu web technology unit 2 Xml2
uptu web technology unit 2 Xml2
Abhishek Kesharwani
 
Specs2
Specs2Specs2
Typedef
TypedefTypedef
Typedef
vaseemkhn
 
Clean code
Clean codeClean code
Clean code
Smita Prasad
 
Intro to python
Intro to pythonIntro to python
Intro to python
Mohamed Essam
 
Data type
Data typeData type
Entity Framework
Entity FrameworkEntity Framework
Entity Framework
vrluckyin
 
Object oriented databases
Object oriented databasesObject oriented databases
Object oriented databases
Sajith Ekanayaka
 
Jason yousef ssis expressions - no notes
Jason yousef   ssis expressions - no notesJason yousef   ssis expressions - no notes
Jason yousef ssis expressions - no notes
jasonyousef
 
Declaration programming 2017
Declaration programming 2017Declaration programming 2017
Declaration programming 2017
Marke Greene
 
DTD
DTDDTD
Flyweight Pattern
Flyweight PatternFlyweight Pattern
Flyweight Pattern
Hüseyin Ergin
 
Structure and Typedef
Structure and TypedefStructure and Typedef
Structure and Typedef
Acad
 
Dot net programming concept
Dot net  programming conceptDot net  programming concept
Dot net programming concept
sandeshjadhav28
 
Xml Presentation-1
Xml Presentation-1Xml Presentation-1
Xml Presentation-1
Sudharsan S
 
Xml dtd
Xml dtdXml dtd
Xml dtd
sana mateen
 
Kotlin generics
Kotlin genericsKotlin generics
Kotlin generics
Wei-Shen Lu
 
Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive
Raj Naik
 
Datastrucure
DatastrucureDatastrucure
Datastrucure
Mohamed Essam
 

What's hot (20)

Dtd
DtdDtd
Dtd
 
uptu web technology unit 2 Xml2
uptu web technology unit 2 Xml2uptu web technology unit 2 Xml2
uptu web technology unit 2 Xml2
 
Specs2
Specs2Specs2
Specs2
 
Typedef
TypedefTypedef
Typedef
 
Clean code
Clean codeClean code
Clean code
 
Intro to python
Intro to pythonIntro to python
Intro to python
 
Data type
Data typeData type
Data type
 
Entity Framework
Entity FrameworkEntity Framework
Entity Framework
 
Object oriented databases
Object oriented databasesObject oriented databases
Object oriented databases
 
Jason yousef ssis expressions - no notes
Jason yousef   ssis expressions - no notesJason yousef   ssis expressions - no notes
Jason yousef ssis expressions - no notes
 
Declaration programming 2017
Declaration programming 2017Declaration programming 2017
Declaration programming 2017
 
DTD
DTDDTD
DTD
 
Flyweight Pattern
Flyweight PatternFlyweight Pattern
Flyweight Pattern
 
Structure and Typedef
Structure and TypedefStructure and Typedef
Structure and Typedef
 
Dot net programming concept
Dot net  programming conceptDot net  programming concept
Dot net programming concept
 
Xml Presentation-1
Xml Presentation-1Xml Presentation-1
Xml Presentation-1
 
Xml dtd
Xml dtdXml dtd
Xml dtd
 
Kotlin generics
Kotlin genericsKotlin generics
Kotlin generics
 
Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive
 
Datastrucure
DatastrucureDatastrucure
Datastrucure
 

Viewers also liked

Photo album of Chinmay &amp; Prachi
Photo album of Chinmay &amp; PrachiPhoto album of Chinmay &amp; Prachi
Photo album of Chinmay &amp; Prachi
Saraf Public School
 
Css 3 overview
Css 3 overviewCss 3 overview
Css 3 overview
dotNETUserGroupDnipro
 
Dadhikar fort
Dadhikar fortDadhikar fort
Dadhikar fort
Saraf Public School
 
Open state concept
Open state conceptOpen state concept
Open state concept
Dominik Wind
 

Viewers also liked (6)

Photo album of Chinmay &amp; Prachi
Photo album of Chinmay &amp; PrachiPhoto album of Chinmay &amp; Prachi
Photo album of Chinmay &amp; Prachi
 
Css 3 overview
Css 3 overviewCss 3 overview
Css 3 overview
 
Balsamiq
BalsamiqBalsamiq
Balsamiq
 
Dadhikar fort
Dadhikar fortDadhikar fort
Dadhikar fort
 
Open state concept
Open state conceptOpen state concept
Open state concept
 
Sonar quality
Sonar qualitySonar quality
Sonar quality
 

Similar to Ef code first

Ef code first
Ef code firstEf code first
Ef code first
ZealousysDev
 
.NET Core, ASP.NET Core Course, Session 13
.NET Core, ASP.NET Core Course, Session 13.NET Core, ASP.NET Core Course, Session 13
.NET Core, ASP.NET Core Course, Session 13
aminmesbahi
 
Intake 37 ef2
Intake 37 ef2Intake 37 ef2
Intake 37 ef2
Mahmoud Ouf
 
Entity Frame Work Core.pptx
Entity Frame Work Core.pptxEntity Frame Work Core.pptx
Entity Frame Work Core.pptx
PrachiPatel779586
 
Intake 38 data access 5
Intake 38 data access 5Intake 38 data access 5
Intake 38 data access 5
Mahmoud Ouf
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
David McCarter
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
David McCarter
 
Entity Framework 4
Entity Framework 4Entity Framework 4
Entity Framework 4
Stefano Paluello
 
Entity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic UnicornsEntity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic Unicorns
Richie Rump
 
dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...
dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...
dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...
dotNet Miami
 
ASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NETASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NET
Randy Connolly
 
Entity framework
Entity frameworkEntity framework
Entity framework
Mehdi jannati
 
Ado.net &amp; data persistence frameworks
Ado.net &amp; data persistence frameworksAdo.net &amp; data persistence frameworks
Ado.net &amp; data persistence frameworks
Luis Goldster
 
Entity Framework Overview
Entity Framework OverviewEntity Framework Overview
Entity Framework Overview
Eyal Vardi
 
PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#
Michael Heron
 
Entity Framework v2 Best Practices
Entity Framework v2 Best PracticesEntity Framework v2 Best Practices
Entity Framework v2 Best Practices
Andri Yadi
 
unit 3.docx
unit 3.docxunit 3.docx
unit 3.docx
Sadhana Sreekanth
 
ADO.NET by ASP.NET Development Company in india
ADO.NET by ASP.NET  Development Company in indiaADO.NET by ASP.NET  Development Company in india
ADO.NET by ASP.NET Development Company in india
iFour Institute - Sustainable Learning
 
Data access
Data accessData access
Data access
Joshua Yoon
 
Murach: How to use Entity Framework EF Core
Murach: How to use Entity Framework EF  CoreMurach: How to use Entity Framework EF  Core
Murach: How to use Entity Framework EF Core
MahmoudOHassouna
 

Similar to Ef code first (20)

Ef code first
Ef code firstEf code first
Ef code first
 
.NET Core, ASP.NET Core Course, Session 13
.NET Core, ASP.NET Core Course, Session 13.NET Core, ASP.NET Core Course, Session 13
.NET Core, ASP.NET Core Course, Session 13
 
Intake 37 ef2
Intake 37 ef2Intake 37 ef2
Intake 37 ef2
 
Entity Frame Work Core.pptx
Entity Frame Work Core.pptxEntity Frame Work Core.pptx
Entity Frame Work Core.pptx
 
Intake 38 data access 5
Intake 38 data access 5Intake 38 data access 5
Intake 38 data access 5
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
 
Entity Framework 4
Entity Framework 4Entity Framework 4
Entity Framework 4
 
Entity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic UnicornsEntity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic Unicorns
 
dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...
dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...
dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...
 
ASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NETASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NET
 
Entity framework
Entity frameworkEntity framework
Entity framework
 
Ado.net &amp; data persistence frameworks
Ado.net &amp; data persistence frameworksAdo.net &amp; data persistence frameworks
Ado.net &amp; data persistence frameworks
 
Entity Framework Overview
Entity Framework OverviewEntity Framework Overview
Entity Framework Overview
 
PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#
 
Entity Framework v2 Best Practices
Entity Framework v2 Best PracticesEntity Framework v2 Best Practices
Entity Framework v2 Best Practices
 
unit 3.docx
unit 3.docxunit 3.docx
unit 3.docx
 
ADO.NET by ASP.NET Development Company in india
ADO.NET by ASP.NET  Development Company in indiaADO.NET by ASP.NET  Development Company in india
ADO.NET by ASP.NET Development Company in india
 
Data access
Data accessData access
Data access
 
Murach: How to use Entity Framework EF Core
Murach: How to use Entity Framework EF  CoreMurach: How to use Entity Framework EF  Core
Murach: How to use Entity Framework EF Core
 

More from dotNETUserGroupDnipro

Mercurial presentation
Mercurial presentationMercurial presentation
Mercurial presentation
dotNETUserGroupDnipro
 
Rx for .net
Rx for .netRx for .net
Soft serve prism
Soft serve prismSoft serve prism
Soft serve prism
dotNETUserGroupDnipro
 
Html5
Html5Html5
Azure for ug
Azure for ugAzure for ug
Azure for ug
dotNETUserGroupDnipro
 

More from dotNETUserGroupDnipro (8)

Mercurial presentation
Mercurial presentationMercurial presentation
Mercurial presentation
 
Rx for .net
Rx for .netRx for .net
Rx for .net
 
Winmobile
WinmobileWinmobile
Winmobile
 
Soft serve prism
Soft serve prismSoft serve prism
Soft serve prism
 
Html5
Html5Html5
Html5
 
Erp microsoft dynamics
Erp microsoft dynamicsErp microsoft dynamics
Erp microsoft dynamics
 
Mvc3
Mvc3Mvc3
Mvc3
 
Azure for ug
Azure for ugAzure for ug
Azure for ug
 

Ef code first

  • 1.
  • 2. Code First Model 1. Define Simple Entities with connection by ID
  • 3. 2. Add virtual properties for lazy loading of Aggregated Fields EF lazy loading is enabled by default Code First Model
  • 4. 3. Remember to preserve name convention EF Code First uses general agreement about names. Code First Model
  • 5. 4. Create Data Context DbContext is similar to EF general Data Context Code First Model
  • 6. Code First Model 5. Create a Repositories
  • 7. 6. What about usage? You can work with it same like a general EF Model Code First Model
  • 8. 7. And what is the result? Code First Model
  • 9. Code First Model 9. Where is Database? Default DB Server is .qlExpress
  • 10.
  • 11.
  • 12. Code First Model Database Initializers System.Data.Entity.Database .IDatabaseInitializer <in TContext> CreateDatabaseIfNotExists DropCreateDatabaseIfModelChanges DropCreateDatabaseAlways
  • 13. Code First Model 1. Create Initializer
  • 14. Code First Model 2 . Register Initializer
  • 15. Code First Model 3 . And we have data if no db is created
  • 16.
  • 17.
  • 18. And Validation Attributes are now also supported Code First Model
  • 19. And using some MVC Magic we receive Code First Model