I recently updated the nuget package for Microsoft.WindowsAzure.Storage to the 3.0 package which also included updates to WCF Data Services Client and it's dependencies. Since the update I get an error when the query is resolving stating:
"There is a type mismatch between the client and the service. Type 'ShiftDigital.Flow.Data.RouteDiagnostic' is not an entity type, but the type in the response payload represents an entity type. Please ensure that types defined on the client match the data model of the service, or update the service reference on the client."
I've done nothing but update the packages and both my application along with a test script I setup in LinqPad generate this exception.
Here is the definition of the entity I've been returning just fine before the update
public class RouteDiagnostic : TableEntity
{
public long? LeadRecipientRouteId { get; set; }
public bool Successful { get; set; }
public int Duration { get; set; }
public string Request { get; set; }
public string Response { get; set; }
public RouteDiagnostic()
: base()
{
this.Timestamp = DateTimeOffset.Now;
this.PartitionKey = GetPartitionKey(this.Timestamp.Date);
this.RowKey = Guid.NewGuid().ToString();
}
public static string GetPartitionKey(DateTime? keyDateTime = null)
{
return string.Format("{0:yyyyyMM}", keyDateTime ?? DateTime.Now);
}
}
Here is the code performing the query
var storageAccount = Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse("...");
var tableClient = storageAccount.CreateCloudTableClient();
var tableContext = new Microsoft.WindowsAzure.Storage.Table.DataServices.TableServiceContext(tableClient);
var diagnostics =
tableContext.CreateQuery<RouteDiagnostic>("RouteDiagnostic")
.Where(rd => rd.PartitionKey == "0201401")
.ToList();
Has something changed that in the latest update or a different way to structure the entities when using data service queries?
Turns out with the update to WCF Data Services 5.6 I needed to add the following attribute to my type:
[DataServiceKey("PartitionKey", "RowKey")]
Once I added the DataServiceKey attribute, all was well again.
When using WCF Data Services, please make your class inherit from TableServiceEntity rather than TableEntity, which already has the DataServiceKey attribute defined. TableEntity is used for the new Table Service Layer in the Windows Azure Storage Client Library. For more information on the new Table Service Layer, please see our blog post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With