【发布时间】:2016-08-27 02:27:48
【问题描述】:
这就是我的模型的样子
public User
{
public string Id { get; set; }
public string Username { get; set; }
public virtual Group Group { get; set; }
}
public Group
{
public string Id { get; set; }
public string Name{ get; set; }
public virtual ICollection<User> Users { get; set; }
}
我使用 Azure Mobile TableController,它使用 OData 进行 CRUD。
现在我尝试通过指定组的 id 来插入新用户,但它给了我一个错误,表明它没有尝试将其与我的用户模型相关联,而是尝试创建新用户:
{
"message": "The operation failed due to a conflict: 'Violation of PRIMARY KEY constraint 'PK_dbo.Groups'. Cannot insert duplicate key in object 'dbo.Groups'. The duplicate key value is (ad934511a82c4b42ae5427b5228737c6).\r\nThe statement has been terminated.'."
}
这就是我的帖子的样子:
POST http://localhost/tables/user?ZUMO-API-VERSION=2.0.0 HTTP/1.1
{
email: 'test@test.com',
password: '#test',
group: {
id: 'ad934511a82c4b42ae5427b5228737c6'
}
}
【问题讨论】:
标签: asp.net azure odata azure-mobile-services