SlideShare a Scribd company logo
Elements of DDD with
      ASP .NET MVC &
Entity Framework Code First
                        Gabriel ENEA, Technical Director
                                           MAXCODE.nl
Co-founder Joobs.ro – the first IT job portal in Romania
                              CodeCamp member / Iași
            gabriel.enea@maxcode.ro / gabrielenea.blogspot.com / @dotnet18




 Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
IT Camp 2011
• Thanks for coming!
• ITCamp is made possible by our sponsors:




      Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
Agenda
# Unit Testing challenges
# Today Architectural Design
# New approach: Domain-Driven-Design
# Today’s Tools (@web)
# Demo

• Q&A

     Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
Application requirements

DEMO


       Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
UNIT TESTING CHALLENGES


   Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
How do you test it?




Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
Testing on components




Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
How do you start building an
       application architecture?
Focus on?
• building an architecture from scratch
• thinking about how to achieve unit testing
• start with modeling the database schema and data relations
• using drag & drop programming
• modeling the domain entities, relations, business rules
• reusing existing code?



• but, in the end, do you achieve 99,99% test code coverage?

         Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
Is unit testing achievable? 100%?
Yes or No? Who knows?

Maybe not! Possible answers:
• The customer doesn't understand this need
• Neither the management staff
• Instead, everyone expects you to write the perfect code

• As developers, every time we say: we need time to do it
  right!

• But, do we need time or we don't know how to achieve it?

        Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
TODAY ARCHITECTURAL DESIGN


   Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
Let's start thinking to architecture
                design
 What? Right, now!?

 Hey, we have only 1 hour to finish this
 presentation! 



 Indeed, but let's try to do something!



     Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
What stops 100% unit testing?
1. Layers
  – How do we design them?
2. Business rules
  – Where and how do we implement?
3. Persistence
  – Should we use an ORM?

  …



       Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
1 - Layers

                         Presentation


                              Business


                          Data Access

Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
1 - Layers – any problems?
                                                                       Presentation


                                                                         Business


Layers Coupling!                                                       Data Access


A strong coupling conducts to a hard way to do:
   – unit testing
   – refactoring
   – agile development
   – or be opened for changes


       Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
2 - Business rules
Where should these be located?
  – Database
  – Business layer
  – User Interface (aka code behind!)


How do we test them?
  – Running the application
  – Automatically, maybe using unit tests
  – Or we should let the customer test them!? 


      Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
And...what's inappropriate here?
// somewhere in the business layer
public class Patient {
   public DateTime Birthdate { get; set; }

      public int Age { // computed value
        get {
           return DateTime.Now.Year - this.Birthdate.Year;
        }
                  Strong coupling!
      }

      public bool IsAdult { // business rule
        get {
           return this.Age >= 18;
        }
      }
...

               Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
3 - Persistence
Requirements
• Persistence Ignorance / POCO
• Help Domain Model stay out of
  infrastructure stuff
• Decide where to store data (NoSQL?)
• Use code generation or an Object Relation
  (O/R) Mapper
  – Metadata mapping
• Support for the Unit of Work pattern

      Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
NEW APPROACH: DDD


  Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
Let's start with a new approach...
Domain-Driven-Design
• What is Domain?

A new default architecture where:
• the database is not the first focus
• the layers are loosely coupled
• the business rules are within the application Domain
• it is easier to achieve unit testing

• Why? Today we have the tools!

        Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
A new default architecture - DDD




   Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
Building blocks of DDD




Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
TODAY'S TOOLS


   Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
Today's tools
(from a web developer perspective)
Dependency Injection frameworks
  – Manage dependencies
  – Castle Windsor, StructureMap, Spring.NET, Unity, ...
ASP.NET MVC 3
  – a mature web development platform based on MVC
    pattern
Entity Framework 4.1 Code First / NHibernate
  – helps you focus on your domain




       Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
What is Dependency Injection?
• = DI.Equals(IoC); // true or false?

• IoC = Inversion of Control
• DI = Dependency Injection

• Helps you to decouple the application dependencies
   – Logging mechanisms (log4net, Enterprise Library Logging
     Application Block, ...)
   – Persistence mechanism (direct access to database, ORM)
   – User Interface dependencies on Domain services
   – Layers


        Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
Dependency Injection


                                                         Log4netLogger


PatientService



                                                        PatientRepositoy




  Premium conference on Microsoft’s Dev and ITPro technologies     @itcampro / #itcampro
Dependency Injection
                                       1) creates
           Builder                                                PatientService




                                     Log4netLogger
2) inject dependencies                                                               3) uses




                                          ILogger



             Premium conference on Microsoft’s Dev and ITPro technologies     @itcampro / #itcampro
ASP.NET MVC 3 and DI support
• Based on MVC pattern
• Provides better support for IoC
   – Views/Controllers
• Model Validation support

• Check IDependencyResolver interface
   – simplify service location and dependency resolution


TService GetService<TService>() { … }

IEnumerable<TService> GetServices<TService>() { … }


        Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
Persistance with EF 4.1 CodeFirst


1st version benefits:
• CodeFirst development
• Better POCO support
• Mapping based on predefined conventions
   (Convention over configuration)
• Fluent API for manual mapping entities to tables, no
   more .edmx files
• Built-in Model-Level Validation
• Dynamic database creation and dropping

        Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
DDD architecture with ASP.NET MVC 3, Unity, Entity Framework
CodeFirst 4.1

DEMO


       Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
Conclusions
Focus on
  –   Analyze application dependencies
  –   Business rules
  –   Do refactoring!
  –   Design your Domain
  –   Don’t forget to do Unit testing




        Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
Resources
Books
• Domain-Driven Design, Tackling Complexity in the
  Heart of Software, by Eric Evans
• Applying Domain-Driven Design and Patterns, With
  Examples in C# and .NET, by Jimmy Nilsson

Online resources
• http://domaindrivendesign.org/
• http://www.infoq.com/minibooks/domai
  n-driven-design-quickly

       Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
Elements of DDD with ASP.NET MVC & Entity Framework Code First

Q&A


       Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro
Don’t forget!
Get your free Azure pass!                            We want your feedback!

• 30+15 days, no CC req’d                        • Win a WP7 smartphone
   – http://bit.ly/ITCAMP11                             – Fill in your feedback forms
   – Promo code: ITCAMP11                               – Raffle: end of the day




        Premium conference on Microsoft’s Dev and ITPro technologies   @itcampro / #itcampro

More Related Content

PDF
Elements of DDD with ASP.NET MVC & Entity Framework Code First
PPTX
Applying EF Code First at Your Job
PPTX
CodeCamp Iasi 10 March 2012 - Gabriel Enea - ASP.NET Web API
PDF
Domain-Driven Design with ASP.NET MVC
PPTX
Implementing DDD with C#
PPTX
Onion Architecture
PPTX
Domain driven design
PPTX
Domain Driven Design Through Onion Architecture
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Applying EF Code First at Your Job
CodeCamp Iasi 10 March 2012 - Gabriel Enea - ASP.NET Web API
Domain-Driven Design with ASP.NET MVC
Implementing DDD with C#
Onion Architecture
Domain driven design
Domain Driven Design Through Onion Architecture

What's hot (20)

PPTX
Implementing DDD Concepts in PHP
PPTX
Microsoft for developers open source and cross platform
PDF
Next18 Extended Targu Mures - Bringing the Cloud to you
PPTX
PHP Framework Battle
PPTX
Google Vertex AI
PPTX
Domain Driven Design for Angular
PPTX
PHP Frameworks & Introduction to CodeIgniter
PPTX
Azure IoT Central
PPTX
"Secure Mobile Apps with the Microsoft Identity Platform", Christos Matskas, ...
PDF
Introduction to-ddd
PPT
Importance Of Being Driven
PDF
Hexagonal architecture message-oriented software design
PDF
Arquitectura hexagonal
PPTX
PL SQLDay Machine Learning- Hands on ML.NET.pptx
PPTX
What's new for Developers in Visual Studio 2013
PDF
Dynamic Apex Binding
PDF
Domain Driven Design
PPTX
AppliFire Blue Print Design Guidelines
PDF
Api chaining(tm)
PDF
Hexagonal architecture - message-oriented software design (Symfony Live Berli...
Implementing DDD Concepts in PHP
Microsoft for developers open source and cross platform
Next18 Extended Targu Mures - Bringing the Cloud to you
PHP Framework Battle
Google Vertex AI
Domain Driven Design for Angular
PHP Frameworks & Introduction to CodeIgniter
Azure IoT Central
"Secure Mobile Apps with the Microsoft Identity Platform", Christos Matskas, ...
Introduction to-ddd
Importance Of Being Driven
Hexagonal architecture message-oriented software design
Arquitectura hexagonal
PL SQLDay Machine Learning- Hands on ML.NET.pptx
What's new for Developers in Visual Studio 2013
Dynamic Apex Binding
Domain Driven Design
AppliFire Blue Print Design Guidelines
Api chaining(tm)
Hexagonal architecture - message-oriented software design (Symfony Live Berli...
Ad

Viewers also liked (7)

PPTX
Dan Solovay - Test Driven Sitecore - SUGCON
PPT
Agile Testing - Challenges
PPTX
OpenTravel XML Object Suite Mechanics
PPTX
Advanced unit testing – real life examples and mistakes
PPTX
Getting started with entity framework
PPTX
Introducing Entity Framework 4.0
PPTX
Entity Framework and Domain Driven Design
Dan Solovay - Test Driven Sitecore - SUGCON
Agile Testing - Challenges
OpenTravel XML Object Suite Mechanics
Advanced unit testing – real life examples and mistakes
Getting started with entity framework
Introducing Entity Framework 4.0
Entity Framework and Domain Driven Design
Ad

Similar to Elements of DDD with ASP.NET MVC & Entity Framework Code First v2 (20)

PDF
ITCamp 2011 - Mihai Tataran, Tudor Damian - Keynote
PPTX
Entity Framework V1 and V2
PDF
70487.pdf
DOC
10265 developing data access solutions with microsoft visual studio 2010
PDF
ITCamp 2011 - Raul Andrisan - What’s new in Silverlight 5
PDF
ITCamp 2011 - Mihai Tataran - Migrating to Azure
DOCX
Actively looking for an opportunity to work as a challenging Dot Net Developer
DOCX
Actively looking for an opportunity to work as a challenging Dot Net Developer
PPTX
Visual Studio 2010 IDE Enhancements - Alex Mackey, Readify
PDF
Mihai Tataran - Building Windows 8 Applications with HTML5 and JS
PPTX
Real World API Design Using The Entity Framework Services
PDF
ITCamp 2011 - Mihai Nadas - Windows Azure interop
PPTX
Entity Framework Today (May 2012)
PPTX
Developing SharePoint 2010 and Silverlight web parts
PDF
ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web ...
PDF
Introduction to WCF RIA Services for Silverlight 4 Developers
PPTX
05 entity framework
PPTX
Silverlight And .Net Ria Services – Building Lob And Business Applications Wi...
PDF
Enforce Consistency through Application Infrastructure - Florin Coros
PPTX
Enforce Consistency through Application Infrastructure
ITCamp 2011 - Mihai Tataran, Tudor Damian - Keynote
Entity Framework V1 and V2
70487.pdf
10265 developing data access solutions with microsoft visual studio 2010
ITCamp 2011 - Raul Andrisan - What’s new in Silverlight 5
ITCamp 2011 - Mihai Tataran - Migrating to Azure
Actively looking for an opportunity to work as a challenging Dot Net Developer
Actively looking for an opportunity to work as a challenging Dot Net Developer
Visual Studio 2010 IDE Enhancements - Alex Mackey, Readify
Mihai Tataran - Building Windows 8 Applications with HTML5 and JS
Real World API Design Using The Entity Framework Services
ITCamp 2011 - Mihai Nadas - Windows Azure interop
Entity Framework Today (May 2012)
Developing SharePoint 2010 and Silverlight web parts
ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web ...
Introduction to WCF RIA Services for Silverlight 4 Developers
05 entity framework
Silverlight And .Net Ria Services – Building Lob And Business Applications Wi...
Enforce Consistency through Application Infrastructure - Florin Coros
Enforce Consistency through Application Infrastructure

More from Enea Gabriel (9)

PPTX
Moving forward with ASP.NET Core
PPTX
The future of ASP.NET / CodeCamp/Iasi 25 Oct 2014
PPSX
Improving the availability of your website
PPTX
Noutăţi în ASP.NET MVC 2
PPTX
FII absolvent!
PPTX
Introducere în ASP.NET MVC prin exemple
PPTX
Magia testelor automate cu ASP.NET MVC
PPTX
Rute cu ASP.NET MVC
PPTX
Model View Controller și ASP.NET MVC + AJAX
Moving forward with ASP.NET Core
The future of ASP.NET / CodeCamp/Iasi 25 Oct 2014
Improving the availability of your website
Noutăţi în ASP.NET MVC 2
FII absolvent!
Introducere în ASP.NET MVC prin exemple
Magia testelor automate cu ASP.NET MVC
Rute cu ASP.NET MVC
Model View Controller și ASP.NET MVC + AJAX

Recently uploaded (20)

PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Encapsulation theory and applications.pdf
PPT
Teaching material agriculture food technology
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Cloud computing and distributed systems.
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Big Data Technologies - Introduction.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Encapsulation theory and applications.pdf
Teaching material agriculture food technology
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Cloud computing and distributed systems.
The Rise and Fall of 3GPP – Time for a Sabbatical?
Dropbox Q2 2025 Financial Results & Investor Presentation
Encapsulation_ Review paper, used for researhc scholars
Reach Out and Touch Someone: Haptics and Empathic Computing
Digital-Transformation-Roadmap-for-Companies.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”

Elements of DDD with ASP.NET MVC & Entity Framework Code First v2

  • 1. Elements of DDD with ASP .NET MVC & Entity Framework Code First Gabriel ENEA, Technical Director MAXCODE.nl Co-founder Joobs.ro – the first IT job portal in Romania CodeCamp member / Iași gabriel.enea@maxcode.ro / gabrielenea.blogspot.com / @dotnet18 Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 2. IT Camp 2011 • Thanks for coming! • ITCamp is made possible by our sponsors: Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 3. Agenda # Unit Testing challenges # Today Architectural Design # New approach: Domain-Driven-Design # Today’s Tools (@web) # Demo • Q&A Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 4. Application requirements DEMO Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 5. UNIT TESTING CHALLENGES Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 6. How do you test it? Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 7. Testing on components Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 8. How do you start building an application architecture? Focus on? • building an architecture from scratch • thinking about how to achieve unit testing • start with modeling the database schema and data relations • using drag & drop programming • modeling the domain entities, relations, business rules • reusing existing code? • but, in the end, do you achieve 99,99% test code coverage? Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 9. Is unit testing achievable? 100%? Yes or No? Who knows? Maybe not! Possible answers: • The customer doesn't understand this need • Neither the management staff • Instead, everyone expects you to write the perfect code • As developers, every time we say: we need time to do it right! • But, do we need time or we don't know how to achieve it? Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 10. TODAY ARCHITECTURAL DESIGN Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 11. Let's start thinking to architecture design What? Right, now!? Hey, we have only 1 hour to finish this presentation!  Indeed, but let's try to do something! Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 12. What stops 100% unit testing? 1. Layers – How do we design them? 2. Business rules – Where and how do we implement? 3. Persistence – Should we use an ORM? … Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 13. 1 - Layers Presentation Business Data Access Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 14. 1 - Layers – any problems? Presentation Business Layers Coupling! Data Access A strong coupling conducts to a hard way to do: – unit testing – refactoring – agile development – or be opened for changes Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 15. 2 - Business rules Where should these be located? – Database – Business layer – User Interface (aka code behind!) How do we test them? – Running the application – Automatically, maybe using unit tests – Or we should let the customer test them!?  Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 16. And...what's inappropriate here? // somewhere in the business layer public class Patient { public DateTime Birthdate { get; set; } public int Age { // computed value get { return DateTime.Now.Year - this.Birthdate.Year; } Strong coupling! } public bool IsAdult { // business rule get { return this.Age >= 18; } } ... Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 17. 3 - Persistence Requirements • Persistence Ignorance / POCO • Help Domain Model stay out of infrastructure stuff • Decide where to store data (NoSQL?) • Use code generation or an Object Relation (O/R) Mapper – Metadata mapping • Support for the Unit of Work pattern Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 18. NEW APPROACH: DDD Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 19. Let's start with a new approach... Domain-Driven-Design • What is Domain? A new default architecture where: • the database is not the first focus • the layers are loosely coupled • the business rules are within the application Domain • it is easier to achieve unit testing • Why? Today we have the tools! Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 20. A new default architecture - DDD Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 21. Building blocks of DDD Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 22. TODAY'S TOOLS Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 23. Today's tools (from a web developer perspective) Dependency Injection frameworks – Manage dependencies – Castle Windsor, StructureMap, Spring.NET, Unity, ... ASP.NET MVC 3 – a mature web development platform based on MVC pattern Entity Framework 4.1 Code First / NHibernate – helps you focus on your domain Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 24. What is Dependency Injection? • = DI.Equals(IoC); // true or false? • IoC = Inversion of Control • DI = Dependency Injection • Helps you to decouple the application dependencies – Logging mechanisms (log4net, Enterprise Library Logging Application Block, ...) – Persistence mechanism (direct access to database, ORM) – User Interface dependencies on Domain services – Layers Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 25. Dependency Injection Log4netLogger PatientService PatientRepositoy Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 26. Dependency Injection 1) creates Builder PatientService Log4netLogger 2) inject dependencies 3) uses ILogger Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 27. ASP.NET MVC 3 and DI support • Based on MVC pattern • Provides better support for IoC – Views/Controllers • Model Validation support • Check IDependencyResolver interface – simplify service location and dependency resolution TService GetService<TService>() { … } IEnumerable<TService> GetServices<TService>() { … } Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 28. Persistance with EF 4.1 CodeFirst 1st version benefits: • CodeFirst development • Better POCO support • Mapping based on predefined conventions (Convention over configuration) • Fluent API for manual mapping entities to tables, no more .edmx files • Built-in Model-Level Validation • Dynamic database creation and dropping Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 29. DDD architecture with ASP.NET MVC 3, Unity, Entity Framework CodeFirst 4.1 DEMO Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 30. Conclusions Focus on – Analyze application dependencies – Business rules – Do refactoring! – Design your Domain – Don’t forget to do Unit testing Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 31. Resources Books • Domain-Driven Design, Tackling Complexity in the Heart of Software, by Eric Evans • Applying Domain-Driven Design and Patterns, With Examples in C# and .NET, by Jimmy Nilsson Online resources • http://domaindrivendesign.org/ • http://www.infoq.com/minibooks/domai n-driven-design-quickly Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 32. Elements of DDD with ASP.NET MVC & Entity Framework Code First Q&A Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro
  • 33. Don’t forget! Get your free Azure pass! We want your feedback! • 30+15 days, no CC req’d • Win a WP7 smartphone – http://bit.ly/ITCAMP11 – Fill in your feedback forms – Promo code: ITCAMP11 – Raffle: end of the day Premium conference on Microsoft’s Dev and ITPro technologies @itcampro / #itcampro