Error while using CosmosDB provider for Entity Framework Core with Azure Tables

99封情书 提交于 2021-02-05 11:42:43

问题


I'm trying to do a simple CRUD application with EF Core and Azure Table (from Azure Storage Account).

I'm passing name of the storage account as database name (The docs aren't exactly clear on that)

services.AddDbContext<HomioDbContext>(options =>    
                options.UseCosmos(
                    "https://homiostorage.table.core.windows.net/",
                    "{Account Key}",
                    databaseName: "{name of storage account}"));

Doing any db operation throws following error (The value for one of the HTTP headers is not in the correct format)

CosmosException;StatusCode=BadRequest;SubStatusCode=0;ActivityId=00000000-0000-0000-0000-000000000000;RequestCharge=0;Message=Response status code does not indicate success: 400 Substatus: 0 Reason: (<?xml version="1.0" encoding="utf-8" standalone="yes"?><error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">  <code>InvalidHeaderValue</code>  <message xml:lang="en-US">The value for one of the HTTP headers is not in the correct format.RequestId:cdef27c9-3002-0084-60dd-d9b8b0000000Time:2020-02-02T15:29:31.9748413Z</message></error>, Request URI: /, RequestStats: , SDK: Windows/10.0.18363 cosmos-netstandard-sdk/3.3.0).;Diagnostics

Been stuck at it for a while now... Could really use some help!


回答1:


As per the documentation here, EF Core Provider for Cosmos DB only supports SQL API only (at least as of writing this answer) and you are using it against Table Storage. That's the reason you're getting this error.



来源:https://stackoverflow.com/questions/60027663/error-while-using-cosmosdb-provider-for-entity-framework-core-with-azure-tables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!