简体   繁体   中英

Internal classes with ADO.NET Entity Framework

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?

实际上,如果你的类是内部的,那么属性是否公开并不重要 - 类本身在项目之外是不可见的,因此永远不能访问属性(除非通过反射)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM