I was helping a reader diagnose an issue with ADO.NET Data Services over the last week. Basically the issue was that just about any table he had in his model wasn't being exposed through the REST service that ADO.NET provided when using LINQ to SQL Entities. When using ADO.NET Entity Framework to generate his model, all was well.
As it turned out, the issue had to do with his primary key name. Apparently, if you are using ADO.NET Data Services on top of a LINQ to SQL DataContext object, you need to make sure that your primary key is defined as "[ENTITY]ID" or "ID". Anything else doesn't seem to work.
So, if your table looks like this:
Your LINQ to SQL entity (dbml) will look like this:
If you then plug that into your ADO.NET Data Service, and then visit your service, you end up with this:
Your entity is nowhere to be found.
It all has to do with the name of your primary key. In this example, if I change the primary key to either "TestTableID" or "ID", I'll see my entity show up.
Things to note about this:
- You don't have to change your underlying data model. You only need to change the LINQ to SQL Entity.
- This only seems to affect LINQ to SQL entities, and not ADO.NET EDM's.