我最近将我的ASP.NET项目(MVC5)升级为使用Storage Library 4.1定位Azure SDK 2.3,当我尝试将任何内容保存到Table Storage时遇到一个奇怪的错误.
错误:
An unhandled exception of type ‘Microsoft.WindowsAzure.Storage.StorageException’ occurred in Microsoft.WindowsAzure.Storage.dll
Additional @R_476_4045@ion: A primitive value was specified; however, a value of the non-primitive type ” was expected.
我的模型通过使用TableServiceContext添加,更新,删除,保存的存储库进入表存储.
我按照这种模式为我的模型:
[System.Data.Services.Common.DataServiceKey(new string[] { "PartitionKey", "RowKey" })]
public class PersisteDalert : Alert, ITableEntity
{
public string PartitionKey
{
get { return this.StudentId; }
set { this.StudentId = value; }
}
public string RowKey
{
get { return this.Id; }
set { this.Id = value; }
}
public DateTime Timestamp { get; set; }
public new int Type { get; set; } //hides Enum type in Alert base class
}
在升级过程中,我需要将所有引用换成
System.Data.Services.*
对于
Microsoft.Data.Services.*
…除OData库外.
内部有什么变化使我的模式不再有效吗?
解决方法:
由于网上没有任何关于此错误的内容,而且这几乎是它所讨论的唯一地方,即使我的上下文与您的上下文不同,我也会添加一个解决方案.错误是完全一样的,所以我猜它起源于同一个地方.
对我来说,这是一个导致问题的继承主键.序列化实体的主键必须是自然的而不是重写.如果Class具有ID属性,则DerivedClass还必须将ID属性声明为“new”,或者必须将ID属性从Class移动到DerivedClass.
这里有更多细节:http://jerther.blogspot.ca/2014/12/aspnet-odata-v4-primitive-value-was.html
我确实认为这是一个错误而不是限制,因为继承的密钥与Entity Framework和Fluent API非常兼容.
我希望这有助于节省一些头发.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。