简体   繁体   English

breeze.js:如何从微风元数据集合中排除表/实体?

[英]breeze.js : how do I exclude tables/entities from breeze metadata collection?

I have a Single-Page application using Entity Framework on the backend and Breeze.js on the client. 我有一个在后端使用Entity Framework并在客户端使用Breeze.js的单页应用程序。 I'm also using the breeze .Net EF classes. 我也在使用轻巧的.Net EF类。 In order for the breeze client to create breeze entities on the client, it calls a controller method named "MetaData". 为了使微风客户端在客户端上创建微风实体,它调用名为“ MetaData”的控制器方法。 This method returns a collection of all the entities in the database, even those that may not be used on the client. 此方法返回数据库中所有实体的集合,即使客户端上可能不使用的实体也是如此。

Even though there is no coding logic in the metadata, it does contain a complete schema of the database. 即使元数据中没有编码逻辑,它也包含数据库的完整架构。 Some of these entities are used for security and business logic, and I wish to not have this entire structure open to the world. 其中一些实体用于安全性和业务逻辑,我不希望将整个结构向世界公开。

Is there a way to exclude entities (not just individual properties) from the breezejs metadata collection? 有没有办法从breezejs元数据集合中排除实体(而不仅仅是单个属性)?

Thanks 谢谢

The easy way is to create a DbContext that has only those classes and relationships that you want to expose. 一种简单的方法是创建一个DbContext ,它仅包含您要公开的那些类和关系。 Use the fluent interface to shrink it down and cauterize relationships that you don't want. 使用流畅的界面可以缩小界面并灼烧不需要的关系。

Then create an instance of an EfContextProvider based on this limited DbContext . 然后基于此有限的DbContext创建EfContextProvider的实例。

You can use this cut-down DbContext exclusively for metadata generation if you wish. 如果需要,可以将此缩减的DbContext专门用于元数据生成。 You can switch to something more robust (wrapped in a different EfContextProvider ) if you must. 如果需要,可以切换到更强大的功能(包装在其他EfContextProvider )。

See the documentation chapter "EF as a Design Tool" . 请参阅文档章节“ EF作为设计工具”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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