无法将值NULL插入列';Id';在azure移动服务器中

无法将值NULL插入列';Id';在azure移动服务器中,azure,azure-mobile-services,Azure,Azure Mobile Services,这是我的代码: using Microsoft.Azure.Mobile.Server; public class MessageController : TableController<Message> { public async Task<IHttpActionResult> PostMessage(Message item) { Message current; try { current = await Inser

这是我的代码:

using Microsoft.Azure.Mobile.Server;
public class MessageController : TableController<Message> 
{
  public async Task<IHttpActionResult> PostMessage(Message item) 
  {
    Message current;
    try
    {
      current = await InsertAsync(item);
    }
    catch (Exception e)
    {
      throw; //  Cannot insert the value NULL into column 'Id'
    }
    return CreatedAtRoute("Tables", new { id = current.Id }, current);
  }
}
使用Microsoft.Azure.Mobile.Server;
公共类MessageController:TableController
{
公共异步任务PostMessage(消息项)
{
信息流;
尝试
{
当前=等待插入同步(项目);
}
捕获(例外e)
{
throw;//无法将值NULL插入列“Id”
}
返回CreatedAtRoute(“Tables”,new{id=current.id},current);
}
}
它告诉我:无法将值NULL插入列“Id”


奇怪的是,生成了Id并将其分配给item.Id,但仍会引发异常。

结果表明,在迁移过程中,不知何故,Id列的默认值没有设置为(newid())

手动设置即可。 CreatedAt列的相同内容应设置为(sysutcdatetime())