SlideShare a Scribd company logo
1 of 22
EF in the Enterprise:
Architecting the Data Layer

Julie Lerman
thedatafarm.com
@julielerman
Boston Code Camp March 2013
Julie Lerman

                                            consultant/mentor
                                            Microsoft MVP, INETA Speaker,
                                            ASPInsider, MCP, VTdotNET Leader
                                            contact
                                            jlerman@theDataFarm.com
                                            www.thedatafarm.com
                                            blog
                                            theDataFarm.com/blog
                                            twitter
                                            @julielerman

Julie Lerman, Boston Code Camp March 2013
                                            book web site
                                            LearnEntityFramework.com
My (best laid) plan


Where EF fits into your architecture
Repository Pattern(s)
Benefits of a Unit of Work
Bounded DbContext for small models
Unit Testing with Entity Framework
Julie Lerman, Boston Code Camp March 2013
Demo
                         Ware
Julie Lerman, Boston Code Camp March 2013
UI
                                            Logic
                                                    LINQ




                            Database
Julie Lerman, Boston Code Camp March 2013
Separation of Concerns


     Extensible
     Adaptable                             Sensible
     Testable
     Maintainable

Julie Lerman, Boston Code Camp March 2013
UI
                                       Service Layer
                                             Bus Layer
Tests
             Repository/Unit of Work
                                   LINQ
Tests

                         Data Layer                      EF

                         Database
 Julie Lerman, Boston Code Camp March 2013
Considering the domain
        Typical Model/DbContext




Julie Lerman, Boston Code Camp March 2013
“bounded context”


                  Delimits the applicability of a particular
                                  model.

                      BOUNDING CONTEXTS gives team
                                  members
                     a clear and shared understanding of
                          what has to be consistent
                                     and
                      what can develop independently.
Julie Lerman, Boston Code Camp March 2013
Focused DbContexts




Julie Lerman, Boston Code Camp March 2013   DB   DB
Focused DbContext




Julie Lerman, Boston Code Camp March 2013   DB   DB
Repository Essential:


                   Encapsulate
                    Redundant
                   Data Access
                      Code
Julie Lerman, Boston Code Camp March 2013
UI
                                       Service Layer
                                             Bus Layer
Tests
             Repository/Unit of Work
                                   LINQ
Tests

                         Data Layer                      EF

                         Database
 Julie Lerman, Boston Code Camp March 2013
Basic Repository
                                            Get




                        Remove                     Store



                                            Send
Julie Lerman, Boston Code Camp March 2013
                                             to
                                             DB
Many variations…


                                                     One repo
                               One repo                 per
                               per type?              object
                                                      graph?
                                             Read
                                            repos?
                                             Write    One repo
                                            repos?      per
                                                      context?
Julie Lerman, Boston Code Camp March 2013
Get


                                                             Get

     Re
    move
                                        Store


                                                 Remove               Store
                      Send
                      to DB


                                                            Send
                                                            to DB
                                Get                                       Customer
               Rem
                                                Store     Aggregate            Orders
               ove
                                                            Root
                                Send
                                 to
                                 DB
Julie Lerman, Boston Code Camp March 2013
                                                                              Addresses
Testing with EF in the Mix


 Integration/                               •EF only or Database?
  Interaction                               •Using database:
     Tests                                    DropCreateDatabaseAlways


                                            •No EF involved: Inconsequential
  Unit Tests                                •EF in the way:
                                               Abstraction/Interfaces
Julie Lerman, Boston Code Camp March 2013
Testability
                                              Classes      System.Data
Fake                                                          .Entity
DbSet
                                      Fake
                 Fake
                    Context & DataA                        Metadata &
        Context & Data B                                   DbContexts



  Tests
Julie Lerman, Boston Code Camp March 2013   Unit of Work
                                                              UI
Julie Lerman

                                            consultant/mentor
                                            Microsoft MVP, INETA Speaker,
                                            ASPInsider, MCP, VTdotNET Leader
                                            contact
                                            jlerman@theDataFarm.com
                                            www.thedatafarm.com
                                            blog
                                            theDataFarm.com/blog
                                            twitter
                                            @julielerman

Julie Lerman, Boston Code Camp March 2013
                                            book web site
                                            LearnEntityFramework.com
Julie Lerman, Boston Code Camp March 2013
Resources

      Pluralsight On-Demand Training: pluralsight.com
      MSDN Developer Center: msdn.com/data/ef
      EF Team: blogs.msdn.com/adonet
      LearnEntityFramework.com
      Programming Entity Framework: DbContext
              by Julie Lerman and Rowan Miller, O’Reilly Media, Feb 22 2012
      Domain Driven Design
              By Eric Evans, Addison-Wesley, 2004
              http://domaindrivendesign.org/
              “Implementing Domain Driven Design”, Vaughn Vernon, 2013
      Separation of Concerns
Julie Lerman, Boston Code Camp March 2013

More Related Content

Viewers also liked

Momentos didácticos.
Momentos didácticos.Momentos didácticos.
Momentos didácticos.valladolid31
 
Clasificación de los textos personales
Clasificación de los textos personalesClasificación de los textos personales
Clasificación de los textos personalesMtra. Zoraida Gpe. Mtz
 
EF6 or EF Core? How Do I Choose?
EF6 or EF Core? How Do I Choose?EF6 or EF Core? How Do I Choose?
EF6 or EF Core? How Do I Choose?Julie Lerman
 
Recensión "Enfermería infantil y dislexia"
Recensión "Enfermería infantil y dislexia"Recensión "Enfermería infantil y dislexia"
Recensión "Enfermería infantil y dislexia"EloNoe
 
GUÍA PARA EL DISEÑO DE PUENTES CON VIGAS Y LOSAS
GUÍA PARA EL DISEÑO DE PUENTES CON VIGAS Y LOSASGUÍA PARA EL DISEÑO DE PUENTES CON VIGAS Y LOSAS
GUÍA PARA EL DISEÑO DE PUENTES CON VIGAS Y LOSASAlberto Arias
 

Viewers also liked (8)

Momentos didácticos.
Momentos didácticos.Momentos didácticos.
Momentos didácticos.
 
классный час культура
классный час культураклассный час культура
классный час культура
 
Metodologia
MetodologiaMetodologia
Metodologia
 
Informe Bijao
Informe BijaoInforme Bijao
Informe Bijao
 
Clasificación de los textos personales
Clasificación de los textos personalesClasificación de los textos personales
Clasificación de los textos personales
 
EF6 or EF Core? How Do I Choose?
EF6 or EF Core? How Do I Choose?EF6 or EF Core? How Do I Choose?
EF6 or EF Core? How Do I Choose?
 
Recensión "Enfermería infantil y dislexia"
Recensión "Enfermería infantil y dislexia"Recensión "Enfermería infantil y dislexia"
Recensión "Enfermería infantil y dislexia"
 
GUÍA PARA EL DISEÑO DE PUENTES CON VIGAS Y LOSAS
GUÍA PARA EL DISEÑO DE PUENTES CON VIGAS Y LOSASGUÍA PARA EL DISEÑO DE PUENTES CON VIGAS Y LOSAS
GUÍA PARA EL DISEÑO DE PUENTES CON VIGAS Y LOSAS
 

More from Julie Lerman

EF Core in Containerized ASP.NET Core APIs
EF Core in Containerized ASP.NET Core APIsEF Core in Containerized ASP.NET Core APIs
EF Core in Containerized ASP.NET Core APIsJulie Lerman
 
Domain-Driven Design with Tender Loving Care (DDD with TLC)
Domain-Driven Design with Tender Loving Care (DDD with TLC)Domain-Driven Design with Tender Loving Care (DDD with TLC)
Domain-Driven Design with Tender Loving Care (DDD with TLC)Julie Lerman
 
What's New in Visual Studio 2017
What's New in Visual Studio 2017What's New in Visual Studio 2017
What's New in Visual Studio 2017Julie Lerman
 
A Tour of EF Core's (1.1) Most Interesting & Important Features
A Tour of EF Core's (1.1) Most Interesting & Important FeaturesA Tour of EF Core's (1.1) Most Interesting & Important Features
A Tour of EF Core's (1.1) Most Interesting & Important FeaturesJulie Lerman
 
Microsoft for developers open source and cross platform
Microsoft for developers  open source and cross platformMicrosoft for developers  open source and cross platform
Microsoft for developers open source and cross platformJulie Lerman
 
Entity Framework and Domain Driven Design
Entity Framework and Domain Driven DesignEntity Framework and Domain Driven Design
Entity Framework and Domain Driven DesignJulie Lerman
 
Entity Framework Today (May 2012)
Entity Framework Today (May 2012)Entity Framework Today (May 2012)
Entity Framework Today (May 2012)Julie Lerman
 
Working With Sql Azure from Entity Framework On-Premises (Julia Lerman)
Working With Sql Azure from Entity Framework On-Premises (Julia Lerman)Working With Sql Azure from Entity Framework On-Premises (Julia Lerman)
Working With Sql Azure from Entity Framework On-Premises (Julia Lerman)Julie Lerman
 
Perspectives on Entity Framework, Julie Lerman
Perspectives on Entity Framework, Julie LermanPerspectives on Entity Framework, Julie Lerman
Perspectives on Entity Framework, Julie LermanJulie Lerman
 
Entity Framework NYC Firestarter
Entity Framework NYC FirestarterEntity Framework NYC Firestarter
Entity Framework NYC FirestarterJulie Lerman
 
Getting Persistence Ignorant with Entity Framework, Julie Lerman
Getting Persistence Ignorant with Entity Framework, Julie LermanGetting Persistence Ignorant with Entity Framework, Julie Lerman
Getting Persistence Ignorant with Entity Framework, Julie LermanJulie Lerman
 
Building n-Tier ASP.NET WebForms with Entity Framework 4, Lerman
Building n-Tier ASP.NET WebForms with Entity Framework 4, LermanBuilding n-Tier ASP.NET WebForms with Entity Framework 4, Lerman
Building n-Tier ASP.NET WebForms with Entity Framework 4, LermanJulie Lerman
 
Persistence Ignorance in Entity Framework 4, Julie Lerman
Persistence Ignorance in Entity Framework 4, Julie LermanPersistence Ignorance in Entity Framework 4, Julie Lerman
Persistence Ignorance in Entity Framework 4, Julie LermanJulie Lerman
 
Persistence Ignorance in Entity Framework 4, Julie Lerman
Persistence Ignorance in Entity Framework 4, Julie LermanPersistence Ignorance in Entity Framework 4, Julie Lerman
Persistence Ignorance in Entity Framework 4, Julie LermanJulie Lerman
 
Entity Framework 4 and WCF
Entity Framework 4 and WCFEntity Framework 4 and WCF
Entity Framework 4 and WCFJulie Lerman
 
Julie Lerman Agile Entity Framework (March 2010)
Julie Lerman Agile Entity Framework (March 2010)Julie Lerman Agile Entity Framework (March 2010)
Julie Lerman Agile Entity Framework (March 2010)Julie Lerman
 
AgileEntity Framework 4
AgileEntity Framework 4AgileEntity Framework 4
AgileEntity Framework 4Julie Lerman
 
Lerman Adx303 Entity Framework 4 In Aspnet
Lerman Adx303 Entity Framework 4 In AspnetLerman Adx303 Entity Framework 4 In Aspnet
Lerman Adx303 Entity Framework 4 In AspnetJulie Lerman
 
Lerman Vvs14 Ef Tips And Tricks
Lerman Vvs14  Ef Tips And TricksLerman Vvs14  Ef Tips And Tricks
Lerman Vvs14 Ef Tips And TricksJulie Lerman
 

More from Julie Lerman (20)

EF Core in Containerized ASP.NET Core APIs
EF Core in Containerized ASP.NET Core APIsEF Core in Containerized ASP.NET Core APIs
EF Core in Containerized ASP.NET Core APIs
 
Domain-Driven Design with Tender Loving Care (DDD with TLC)
Domain-Driven Design with Tender Loving Care (DDD with TLC)Domain-Driven Design with Tender Loving Care (DDD with TLC)
Domain-Driven Design with Tender Loving Care (DDD with TLC)
 
What's New in Visual Studio 2017
What's New in Visual Studio 2017What's New in Visual Studio 2017
What's New in Visual Studio 2017
 
A Tour of EF Core's (1.1) Most Interesting & Important Features
A Tour of EF Core's (1.1) Most Interesting & Important FeaturesA Tour of EF Core's (1.1) Most Interesting & Important Features
A Tour of EF Core's (1.1) Most Interesting & Important Features
 
Microsoft for developers open source and cross platform
Microsoft for developers  open source and cross platformMicrosoft for developers  open source and cross platform
Microsoft for developers open source and cross platform
 
Entity Framework and Domain Driven Design
Entity Framework and Domain Driven DesignEntity Framework and Domain Driven Design
Entity Framework and Domain Driven Design
 
RavenDB Overview
RavenDB OverviewRavenDB Overview
RavenDB Overview
 
Entity Framework Today (May 2012)
Entity Framework Today (May 2012)Entity Framework Today (May 2012)
Entity Framework Today (May 2012)
 
Working With Sql Azure from Entity Framework On-Premises (Julia Lerman)
Working With Sql Azure from Entity Framework On-Premises (Julia Lerman)Working With Sql Azure from Entity Framework On-Premises (Julia Lerman)
Working With Sql Azure from Entity Framework On-Premises (Julia Lerman)
 
Perspectives on Entity Framework, Julie Lerman
Perspectives on Entity Framework, Julie LermanPerspectives on Entity Framework, Julie Lerman
Perspectives on Entity Framework, Julie Lerman
 
Entity Framework NYC Firestarter
Entity Framework NYC FirestarterEntity Framework NYC Firestarter
Entity Framework NYC Firestarter
 
Getting Persistence Ignorant with Entity Framework, Julie Lerman
Getting Persistence Ignorant with Entity Framework, Julie LermanGetting Persistence Ignorant with Entity Framework, Julie Lerman
Getting Persistence Ignorant with Entity Framework, Julie Lerman
 
Building n-Tier ASP.NET WebForms with Entity Framework 4, Lerman
Building n-Tier ASP.NET WebForms with Entity Framework 4, LermanBuilding n-Tier ASP.NET WebForms with Entity Framework 4, Lerman
Building n-Tier ASP.NET WebForms with Entity Framework 4, Lerman
 
Persistence Ignorance in Entity Framework 4, Julie Lerman
Persistence Ignorance in Entity Framework 4, Julie LermanPersistence Ignorance in Entity Framework 4, Julie Lerman
Persistence Ignorance in Entity Framework 4, Julie Lerman
 
Persistence Ignorance in Entity Framework 4, Julie Lerman
Persistence Ignorance in Entity Framework 4, Julie LermanPersistence Ignorance in Entity Framework 4, Julie Lerman
Persistence Ignorance in Entity Framework 4, Julie Lerman
 
Entity Framework 4 and WCF
Entity Framework 4 and WCFEntity Framework 4 and WCF
Entity Framework 4 and WCF
 
Julie Lerman Agile Entity Framework (March 2010)
Julie Lerman Agile Entity Framework (March 2010)Julie Lerman Agile Entity Framework (March 2010)
Julie Lerman Agile Entity Framework (March 2010)
 
AgileEntity Framework 4
AgileEntity Framework 4AgileEntity Framework 4
AgileEntity Framework 4
 
Lerman Adx303 Entity Framework 4 In Aspnet
Lerman Adx303 Entity Framework 4 In AspnetLerman Adx303 Entity Framework 4 In Aspnet
Lerman Adx303 Entity Framework 4 In Aspnet
 
Lerman Vvs14 Ef Tips And Tricks
Lerman Vvs14  Ef Tips And TricksLerman Vvs14  Ef Tips And Tricks
Lerman Vvs14 Ef Tips And Tricks
 

Recently uploaded

UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 

Recently uploaded (20)

UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 

Architecting the Data Layer with EF in the Enterprise

  • 1. EF in the Enterprise: Architecting the Data Layer Julie Lerman thedatafarm.com @julielerman Boston Code Camp March 2013
  • 2. Julie Lerman consultant/mentor Microsoft MVP, INETA Speaker, ASPInsider, MCP, VTdotNET Leader contact jlerman@theDataFarm.com www.thedatafarm.com blog theDataFarm.com/blog twitter @julielerman Julie Lerman, Boston Code Camp March 2013 book web site LearnEntityFramework.com
  • 3. My (best laid) plan Where EF fits into your architecture Repository Pattern(s) Benefits of a Unit of Work Bounded DbContext for small models Unit Testing with Entity Framework Julie Lerman, Boston Code Camp March 2013
  • 4. Demo Ware Julie Lerman, Boston Code Camp March 2013
  • 5. UI Logic LINQ Database Julie Lerman, Boston Code Camp March 2013
  • 6. Separation of Concerns Extensible Adaptable Sensible Testable Maintainable Julie Lerman, Boston Code Camp March 2013
  • 7. UI Service Layer Bus Layer Tests Repository/Unit of Work LINQ Tests Data Layer EF Database Julie Lerman, Boston Code Camp March 2013
  • 8. Considering the domain Typical Model/DbContext Julie Lerman, Boston Code Camp March 2013
  • 9. “bounded context” Delimits the applicability of a particular model. BOUNDING CONTEXTS gives team members a clear and shared understanding of what has to be consistent and what can develop independently. Julie Lerman, Boston Code Camp March 2013
  • 10.
  • 11. Focused DbContexts Julie Lerman, Boston Code Camp March 2013 DB DB
  • 12. Focused DbContext Julie Lerman, Boston Code Camp March 2013 DB DB
  • 13. Repository Essential: Encapsulate Redundant Data Access Code Julie Lerman, Boston Code Camp March 2013
  • 14. UI Service Layer Bus Layer Tests Repository/Unit of Work LINQ Tests Data Layer EF Database Julie Lerman, Boston Code Camp March 2013
  • 15. Basic Repository Get Remove Store Send Julie Lerman, Boston Code Camp March 2013 to DB
  • 16. Many variations… One repo One repo per per type? object graph? Read repos? Write One repo repos? per context? Julie Lerman, Boston Code Camp March 2013
  • 17. Get Get Re move Store Remove Store Send to DB Send to DB Get Customer Rem Store Aggregate Orders ove Root Send to DB Julie Lerman, Boston Code Camp March 2013 Addresses
  • 18. Testing with EF in the Mix Integration/ •EF only or Database? Interaction •Using database: Tests DropCreateDatabaseAlways •No EF involved: Inconsequential Unit Tests •EF in the way: Abstraction/Interfaces Julie Lerman, Boston Code Camp March 2013
  • 19. Testability Classes System.Data Fake .Entity DbSet Fake Fake Context & DataA Metadata & Context & Data B DbContexts Tests Julie Lerman, Boston Code Camp March 2013 Unit of Work UI
  • 20. Julie Lerman consultant/mentor Microsoft MVP, INETA Speaker, ASPInsider, MCP, VTdotNET Leader contact jlerman@theDataFarm.com www.thedatafarm.com blog theDataFarm.com/blog twitter @julielerman Julie Lerman, Boston Code Camp March 2013 book web site LearnEntityFramework.com
  • 21. Julie Lerman, Boston Code Camp March 2013
  • 22. Resources  Pluralsight On-Demand Training: pluralsight.com  MSDN Developer Center: msdn.com/data/ef  EF Team: blogs.msdn.com/adonet  LearnEntityFramework.com  Programming Entity Framework: DbContext  by Julie Lerman and Rowan Miller, O’Reilly Media, Feb 22 2012  Domain Driven Design  By Eric Evans, Addison-Wesley, 2004  http://domaindrivendesign.org/  “Implementing Domain Driven Design”, Vaughn Vernon, 2013  Separation of Concerns Julie Lerman, Boston Code Camp March 2013