I have a WPF application that uses a WCF services to perform operations on entities using EF4.
My project structure is as follows:
Project: EntityObjects
- this is where the edmx file lives
Project: WCFService
- References EntityObjects
- Has data contracts to perform actions on entities
- Has three different svc files, called Partner.svc, Section.svc, Scheme.svc
Project: DataLayer
- has service references to Partner.svc, section.svc, scheme.svc
The problem is that the DataLayer project then has ambiguous references to objects as each svc file returns its own references of the entity objects.
How do I get around this?
It will not work this way. If you want to have same data contract types among all three service references you must use data contract sharing. That means that your data contracts must be provided to client project in separate assembly prior to adding service references. Most often this means that you will share data contract assembly between server and client. In your case it means sharing EntityObjects with whole EF stuff – that is bad.
There are multiple solutions:
Last two choices are more about architecture of your application.