Wrox Programmer Forums
BOOK: Patterns, Principles and Practices of Domain-Driven Design
This is the forum to discuss the Wrox book Patterns, Principles and Practices of Domain-Driven Design by Scott Millett; ISBN: 978-1-118-71470-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Patterns, Principles and Practices of Domain-Driven Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 5th, 2015, 11:44 AM
Registered User
Join Date: Jun 2015
Posts: 4
Thanks: 2
Thanked 0 Times in 0 Posts
Default EF Repository


I have a few questions regarding chapter 21, Entity Framework repository example:
- The EF example has additional data model and snapshot dto as compared to NHibernate example, is that because it's not possible to configure EF to map private properties of domain entities?

- Is snapshot dto sufficient in this case? .i.e. The EF mapping is configured to use snapshot instead of data model. I feel there are too many mapping (domain model -> snapshot -> data model) in the example.

- The EF repositories have Save() method, but as I know, EF does track changes of entities once it loads entities into memory. So is Save() method redundant?

Many thanks
Old July 15th, 2015, 03:49 AM
Wrox Author
Join Date: May 2015
Posts: 59
Thanks: 1
Thanked 5 Times in 5 Posts


We haven't forgotten about this question. Scott is the EF man and he'll answer when he's back online.

Apologies for the delay.
Old August 26th, 2015, 03:26 AM
Registered User
Join Date: Jul 2015
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts

I think the point of creating the snapshot of the domain entities/value objects is so that the domain model and data model do not bleed into each other, which is what is bound to happen if you simply use the snapshot as your DTO. The memento pattern on display in this example is the solution to that problem.

I think the dynamic change tracking in EF makes extra requirements on the entity classes you use (all setters/getters must be declared virtual, etc.). I don't think that's being done here.

In fact, to get this example to work, I had to add a SaveChanges() call to the end of the BidHistoryRepository's Add method in order to get the bids saved to the BidHistory table. So, at the end of the IBidHistoryRepository.Add() method, I have this:

// Original last line of the method

// Added line to save the BidDTO to the database

This got the EF example working like the others.

Thank you very much,


Similar Threads
Thread Thread Starter Forum Replies Last Post
Repository in Domain varghesep BOOK: Patterns, Principles and Practices of Domain-Driven Design 2 July 4th, 2015 08:17 AM
Scafolding for non-EF? RKevinBurton BOOK: Professional ASP.NET MVC 4 0 March 24th, 2015 09:21 AM
connectionString using EF nanonerd ASP.NET 4 General Discussion 6 July 19th, 2012 01:28 PM
SVN Repository Hannes BOOK: Professional Joomla! ISBN: 978-0-470-13394-1 2 August 30th, 2010 05:17 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.