I hope the following will save some people time. The above exception occurs while developing using the July 2009 CTP of Windows Azure. The following query throws the above exception when the oauthConsumers table has no entry. I have not checked if it will occur if there is already an entry in the table or whether it occurs when published to the cloud.
var result = db.oauthConsumers.Where(x => x.PartitionKey == "user" && x.RowKey == userId).SingleOrDefault();
I had tried doing the following the solve the above problem
- Press the huge Reset button in the Development Storage tool.
- Delete the Test Storage tables created in SQL Express and recreated them.
- Checked, double-checked, and triple-checked the entity declarations and table names.
- Various combinations of the above.
But no joy. It turns out that the above query should be written as follows
var result = db.oauthConsumers.Where(x => x.RowKey == userId && x.PartitionKey == "user").SingleOrDefault();
??!??!! I'm not going to dig any deeper into this but an explanation to why the above fixes the exception would be great.