DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Building Scalable Real-Time Apps with AstraDB and Vaadin
Register Now

Trending

  • Cypress Tutorial: A Comprehensive Guide With Examples and Best Practices
  • Five Java Books Beginners and Professionals Should Read
  • Microservices Decoded: Unraveling the Benefits, Challenges, and Best Practices for APIs
  • Which Is Better for IoT: Azure RTOS or FreeRTOS?

Trending

  • Cypress Tutorial: A Comprehensive Guide With Examples and Best Practices
  • Five Java Books Beginners and Professionals Should Read
  • Microservices Decoded: Unraveling the Benefits, Challenges, and Best Practices for APIs
  • Which Is Better for IoT: Azure RTOS or FreeRTOS?
  1. DZone
  2. Coding
  3. Frameworks
  4. Let's do Some DDD With Entity Framework Core 3!

Let's do Some DDD With Entity Framework Core 3!

Let's get a handle on DDD Entity Framework!

David Guida user avatar by
David Guida
CORE ·
Nov. 01, 19 · Tutorial
Like (8)
Save
Tweet
Share
27.04K Views

Join the DZone community and get the full member experience.

Join For Free

open-library-with-long-staircase

A few days ago, Microsoft released Entity Framework Core 3, introducing a lot of improvements in both functionality and performance (and some breaking change as well).

Now, we have full support for very cool stuff like C# 8, Async Enumerables, plus a brand new LINQ provider.

I’ve been using a lot of Entity Framework in my daily job, but of course, before upgrading a project ‘s dependency to a major version, there’s always some testing to do. As I often do, I decided to write a small demo and try out some of these new functionalities. You can find all the sources on GitHub.

My goal for this project was to model a bunch of Aggregates and Value Objects with proper Persistence Ignorance (e.g. I don’t want to pollute my business logic classes with code responsible for storing and retrieving data.

You may also like: How to Configure Entity Framework Caching.

Luckily, Entity Framework Core offers the possibility to configure the Entity/Table mapping using a nice Fluent Interface, avoiding attributes on our properties.

We have basically two options. The first one is to write all the configuration code in the OnModelCreating() method of our DbContext. It's quick and easy, but it leads to a lot of very confusing code.

A much cleaner option is to use the database diagram generated with https://sqldbm.com:

Orders Schema

Then the code will:
  1. Create some products.
  2. Add just one product to a quote and save it.
  3. Update the quote adding another product.
  4. Create an order from that quote.
  5. Add another product to the quote.
  6. Create another order from the quote.
Output from script

In the next post, we’re going to take a look at the code and talk about each Entity configuration. Stay tuned!


Further Reading

  • Domain-Driven Design Demystified.
  • Teach Yourself DDD in 5 Minutes.
  • 10 Easy Steps to a Complete Understanding of SQL.
Entity Framework Database Framework

Published at DZone with permission of David Guida. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • Cypress Tutorial: A Comprehensive Guide With Examples and Best Practices
  • Five Java Books Beginners and Professionals Should Read
  • Microservices Decoded: Unraveling the Benefits, Challenges, and Best Practices for APIs
  • Which Is Better for IoT: Azure RTOS or FreeRTOS?

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: