Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • 1
    The most significant problem you are going to encounter with Entity Framework if you intend to take the hard stance and provide separate objects in another layer is that you are going to lose change tracking. This has an impact on performance and greatly increases the difficulty and complexity of using Entity Framework as a Data Access Layer. Commented Jul 8, 2020 at 0:13
  • 1
    @RobertHarvey: You can actually get around the loss of change tracking if you use interfaces instead of objects, and both the domain object and entity implement the interface. E.g. if I pass a Domain.Foo : IFoo to my DAL (as an IFoo) it gets converted to a DAL.Foo : IFoo, but my DAL returns DAL.Foo (as an IFoo). If I then take something from the DAL and then hand it back to the DAL, it's actually still using the same tracked DAL.Foo object. This does come with some additional mapping logic and requires some extra effort, but it works. Commented Jul 8, 2020 at 7:43