开发者

WCF DataService with EF CTP 5 CodeOnly DbContext

开发者 https://www.devze.com 2023-02-13 19:27 出处:网络
I am trying to build a WCF DataService on top of a Code Only DbContext. However as soon as I add the first DbSet property to my DbContext I get \"Request Error\" when accessing the .svc.

I am trying to build a WCF DataService on top of a Code Only DbContext. However as soon as I add the first DbSet property to my DbContext I get "Request Error" when accessing the .svc.

All I need to get 开发者_StackOverflow中文版the error is to have this DbContext:

public class JukeboxContext : DbContext
{
    public DbSet<Song> Songs { get; set; }
}

and then do a basic WCF DataService based on it, and the error happens when i run the service.

Any ideas on what I need to do?


Turnes out the exception means that it can't resolve which field is the primary key. The easy way to go is to name it ID or ID - otherwise the DataServiceKey attribute will let you use composite keys

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号