Reputation: 12695
I have 2 projects
DAL
Main
in the DAL
, I create ad DataService
class and also I generate the EF context class. How to hide that auto generated EF classes from being accessible from the Main
project ? I want to have access only to the DataService
class.
I cannot modify the EF entities and put there the internal
modifier because after update the context it will be overriden.
Upvotes: 0
Views: 78
Reputation: 10538
If you are trying to make entities ignorant of schema, use something like AutoMapper or use in-code configuration instead of .edmx
Upvotes: 1
Reputation: 33139
Put the EF model and its generated classes in a separate project, reference that project from the DAL project, and then you can choose what you expose from the public class DataService
.
Of course, if you expose entities from your EF model, and DataService is a regular .NET class instead of a WCF service, then your client will also need to reference the EF project...
If you really want to hide the entities from the client, the client is not allowed to use them at all, and you'll have to provide other ways for the client to read/write data (such as DTO's that you create in a separate project or in the DAL project).
Upvotes: 1