Wcf 数据服务反射提供程序抱怨不相关的类型
我有两项服务,客户服务和产品服务。它们是独立的,并且每个都有自己的实体类型。当我将它们分成两个不同的项目时,它们工作正常。但是,当它们位于同一项目内时,当我尝试导航到每个服务 url 时,会收到类似于以下内容的错误。
服务器在处理请求时遇到错误。异常消息是“类型”Common.Model.Product”具有实体类型的属性“类别”。该属性在数据上下文中没有相应的实体集,或者其继承类型之一具有相应的实体集。为此属性的实体类型指定 IgnoreProperties 属性,或使用在数据上下文中具有相应实体集的属性类型。'
如果出现此错误,我正在尝试导航客户服务 URL,但它抱怨从未在客户服务内部使用或引用的产品服务实体类型。同样,当我尝试导航产品服务 URL 时,我收到此错误:
服务器在处理请求时遇到错误。异常消息是“Common.Model.Branch”类型上的属性“Customers”不是有效的属性。不支持类型为基元集合或复杂类型的属性。
同样,该错误与产品服务中使用的 EntityType 有关,而在客户服务中从未使用或引用。
我想重复一遍,如果我将这些服务及其实体类型拆分到单独的项目中,则这两个服务都可以正常运行。
有办法解决这个问题吗?
I have two services, Customer service and Product service. They are independent and each have their own Entity Types. They work ok, when I split them to two different project. However, when they are inside the same project, when I try to navigate to each service url I get a error similar to the following.
The server encountered an error processing the request. The exception message is 'Type 'Common.Model.Product' has property 'Category' of entity type. Either this property has no corresponding entity set in the data context or one of its inherited types has a corresponding entity set. Specify IgnoreProperties attribute on the entity type for this property or use a property type that has a corresponding entity set in the data context.'
In case of this error, I'm tryiing to naviagate Customer Service URL but it complains about a Product Service entity type that is never used or referenced inside Customer Service. Similarily, when I try to Navigate Product Service URL I get this error:
The server encountered an error processing the request. The exception message is 'The property 'Customers' on type 'Common.Model.Branch' is not a valid property. Properties whose types are collection of primitives or complex types are not supported.'
Again, the error is about EntityType that is used in Product Service and is never used or referenced in the Customer Service.
I'd like to repeat that if I split these services and their Entity Types in separate projects, both services run fine.
Is there a way to resolve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是这两个服务的实体类型派生自相同的基类:
无论出于何种原因(我仍然不太明白为什么),这使得反射提供程序遍历每个服务的所有派生类。当我删除这种依赖关系时,服务开始工作。
The issue was that the Entity Types for both services were derived from the same base class:
For whatever reason (I still not quite understand why) this made the reflection provider walk all the derived classes for each service. When I removed this dependency the services started working.