将CosmosDB提供程序用于带有Azure表的Entity Framework Core时出错 [英] Error while using CosmosDB provider for Entity Framework Core with Azure Tables

查看:37
本文介绍了将CosmosDB提供程序用于带有Azure表的Entity Framework Core时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用EF Core和Azure Table(来自Azure存储帐户)创建一个简单的CRUD应用程序.

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}"));

执行任何数据库操作都会引发以下错误(其中一个HTTP标头的值格式不正确)

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!

推荐答案

根据文档

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.

这篇关于将CosmosDB提供程序用于带有Azure表的Entity Framework Core时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆