0
votes

I am messing around with the EF4.1. I want to keep my domain and my DAL separate. My domain contains the basic entity classes and the interfaces for repositories. The DAL contains implementations of those repositories.

My issue is that I have to edit my domain to use the EF. For example, a 'Person' that has an 'Address', now has an 'AddressId' and a 'virtual Address'. I also keep annotations in my domain layer now. I'm not too happy with this since this means I'm changing the core of my application to use the EF. I'm also introducing irrelevant data since an Address doesn't need to have an ID in the context of my application; only in the database. What if tomorrow I write a new DAL layer that gets my objects from a web service or an XML file or something?

Is there a way around this? I was thinking of keeping the EF entities in the DAL layer and mapping them to my domain classes in the repositories, but wouldn't that be a huge performance hit?

1

1 Answers

1
votes

I don't see a point in having your EF entities in the DAL and your repositories somewhere else, not to mention that there would be an inevitable performance hit for translating those EF entities into the domain classes.

Instead, you might want to consider using the EF Fluent API, as shown here and here as well. You can then put the DbContext class in your DAL, put all of the Fluent mappings there, and leave your domain classes clean and sparkling.