views:

180

answers:

2

I'm using Entity Framework for creation of my Data Access Layer and I want for all of my classes to be internal.

I know it is possible to manually assign it in the designer for each class.

UPDATE I found that my initial statement

But looks like it also requires to set internal modifier for each single property in every class! I have about 30+ entities and it will be a huge work to do.

was incorrect. I was missing that when I set access on Entity Type I need to set an appropriate access on Entity Set as well.

Do you know any ideas how to set a 'default access' for the entire model?

+1  A: 

What are you trying to achieve exactly? If every class in your model was declared internal and all of it's properties were declared internal, it would make your model useless. Something will need to access it and work with it sometime...

Are you trying to prevent a specific usage of the model ? There are better ways to do this.

UPDATE: It looks like VS2010 will allow an internal ObjectContext through T4 templating. Have a look here: http://blogs.msdn.com/efdesign/archive/2009/01/22/customizing-entity-classes-with-t4.aspx

Matthew
By design classes from this `DataAccess` library should be used only by another very particular `Model` assembly. I will have `InternalsVisibleTo` attribute in `DataAccess` so only `Model` can use its classes.
Regent
If you need them marked internal, you're going to have to manually modify the designer file. If you're model never changes, that's not really a problem...but if it changes, you may be in a situation where the designer file (which is auto generated) overwrites your changes. If you can use 2010, it looks like T4 templates allow you to achieve what you're after (http://blogs.msdn.com/efdesign/archive/2009/01/22/customizing-entity-classes-with-t4.aspx)
Matthew
A: 

Actually if your class is internal, it doesn't matter if the properties are public - the class itself isn't visible outside your project, so the properties can never be accessed (unless through reflection)

Steffen
True, but as I found my problem was because I missed that if I set internal visibility on `Entity Type` then I also need to set at least internal on `Entity Set` as well.
Regent
But unfortunately I haven't found the way to set visibility on `EntityContainer` level.
Regent