WCF 数据服务错误 "The given name ' Foo' 未在实体集中找到”

标签 wcf entity-framework .net-4.0

我正在开发 WCF 数据服务来公开数据库。我想提供对其中一张表的访问(称为“Foo”),因此我将其放入 InitializeService我的方法DatabaseService.svc.cs :

config.SetEntitySetAccessRule("Foo", EntitySetRights.AllRead);

但是,当服务初始化时,它会抛出 ArgumentException带有消息“在实体集中找不到给定的名称‘Foo’。”

该表肯定在 .edmx 文件中,名称、大小写和拼写都正确。它也在 .Designer.cs文件,像这样:
[EdmEntityTypeAttribute(NamespaceName="FooDBModel", Name="Foo")]
[Serializable()]
[DataContractAttribute(IsReference=true)]
public partial class Foo : EntityObject

服务类本身声明为:
public class FooDatabaseService : DataService<FooDBEntities>

最佳答案

您是否尝试过使用完全限定名称?

关于WCF 数据服务错误 "The given name ' Foo' 未在实体集中找到”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5474673/

相关文章:

c# - 有没有办法将 linq 表达式中的多个值与通用列表进行比较?

c# - 如何使用 Entity Framework 实现搜索功能?

c# - 生成随机字母数字代码 C#

c# - WCF 双工服务使用 net tcp : "Stream Security is required..."

wcf - 如何在 Restful WCF 服务中管理 session

.net - "Could not establish trust relationship for the SSL/TLS secure channel"具有有效证书

c# - EF Core 中的数据库资源授权

c# - 如果 fiddler 2 可以通过 HTTPS 解密所有调用,那么 SSL 有什么意义?

c# - 自使用 .Net 4.0 以来 visual studio Release模式中的 InvalidOperationException

c# - 如何在 WCF 中使用 DataContract/DataMember 序列化 Func<int, int>(甚至是一般委托(delegate))类型字段