实体框架:[使用内部访问说明符设置所有实体]
根据我的应用程序,我需要将我的业务实体与 EF4 创建的实体分开。我需要限制实体仅访问从它们被翻译(使用翻译器)到在业务和服务层共享的业务实体的存储库。我想通过将它们指定为内部来限制它们。现在我的应用程序中有 40 多个实体,因此手动将它们设置为内部是一项困难的工作。在其中一个论坛中,答案建议使用 T4 模板。但即使这些模板也是从实体框架访问说明符中读取的。当我尝试手动尝试将所有属性和类访问说明符指定为内部时,它给我一个错误,指出实体集也应该设置为内部,但没有相同的选项。 我正在使用 VS 2010 和 Entity Framework 4。有什么建议吗???
By virtue of my application, I need to seperate my business entities from the entities created by EF4. I need to restrict the entities to only access the repository from where they are translated (using translator) to business entities shared at business and service layer. I thought of restricting them by specifying them as internal. Now there are more than 40 entities in my application so manually setting them as internal is a difficult job. In one of the forums the answers suggested using the T4 templates. But even those templates read from the entity framework access specifier. When I try to manually try to specify all the properties and class access specifiers as internal it gives me an error saying that the entity set should also be set to internal, but there is no option for the same.
I am using VS 2010 and Entity Framework 4. Any suggestions???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
单击 DataModel.edmx 的白色背景。在属性部分中查找“实体容器访问”并将其更改为内部。
Click on the white background of your DataModel.edmx. In the properties section look for "Entity Container Access" and change it to Internal.
用正则表达式进行搜索和替换很困难吗?右键单击您的 EDMX,以 XML 形式打开,然后按 Ctrl+H。
搜索字符串示例为:
替换字符串示例为:
为简单起见,我还没有检测到现有的
TypeAccess
。您可以根据需要使正则表达式变得复杂。您必须选中该框才能告诉 VS 使用正则表达式。
It's difficult to do a search and replace with a regex? Right click your EDMX, open as XML, and press Ctrl+H.
An example search string is:
An example replace string is:
For simplicity, I haven't detected existing
TypeAccess
. You can make the regex as complicated as you like.You have to check the box to tell VS to use the regex.