C# .NET 3.1:“;更新条目时出错。有关详细信息,请参见内部异常;

C# .NET 3.1:“;更新条目时出错。有关详细信息,请参见内部异常;,c#,asp.net-core,C#,Asp.net Core,我尝试创建一个包含图像的房间日志,它报告了这个错误 Microsoft.EntityFrameworkCore.DbUpdateException:更新条目时出错。有关详细信息,请参见内部异常 这是控制器 [HttpPost] public async Task<IActionResult> Create([FromForm]RoomCreateRequest request) { var roomId = await _manageRoomService.

我尝试创建一个包含图像的房间日志,它报告了这个错误


Microsoft.EntityFrameworkCore.DbUpdateException:更新条目时出错。有关详细信息,请参见内部异常

这是控制器

[HttpPost]
public async Task<IActionResult> Create([FromForm]RoomCreateRequest request)
    {
        var roomId = await _manageRoomService.Create(request);

        if (roomId == null)
            return BadRequest();

        var room = await _manageRoomService.GetById(roomId, request.LanguageId);

        return CreatedAtAction(nameof(GetById), new { id = roomId }, room);
    }
这是RoomCreateRequest类

public class RoomCreateRequest
 {
    public string Id { set; get; }
    public decimal Price { set; get; }
    public string NumberRoom { set; get; }
    public string Name { set; get; }

    public string Description { set; get; }
    public string SeoDescription { set; get; }
    public string SeoTitle { set; get; }

    public string SeoAlias { get; set; }
    public string LanguageId { set; get; }

    public IFormFile ThumbnailImage { get; set; }
 }

但是,如果我不添加图像,它会工作。

在异常的顶部,它会显示
无效的列名'IsDefault'
。为了解决此问题,您应该在
房间
表中设置名为
IsDefault
的列


※我假设根据您的上下文对象将您的表命名为
Room
,在您的情况下可能会有所不同

,内部异常是什么?基于包含错误的链接图像-与数据库存在某种不匹配。你忘了运行一些迁移吗?谢谢你,默奇!
// SaveFile Image
    private async Task<string> SaveFile(IFormFile file)
    {
        var originalFileName = 
        ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"');
        var fileName = $"{Guid.NewGuid()}{Path.GetExtension(originalFileName)}";
        await _storageService.SaveFileAsync(file.OpenReadStream(), fileName);
        return fileName;
    }
public async Task SaveFileAsync(Stream mediaBinaryStream, string fileName)
{
        var filePath = Path.Combine(_userContentFolder, fileName);
        using var output = new FileStream(filePath, FileMode.Create);
        await mediaBinaryStream.CopyToAsync(output);
}
public class RoomCreateRequest
 {
    public string Id { set; get; }
    public decimal Price { set; get; }
    public string NumberRoom { set; get; }
    public string Name { set; get; }

    public string Description { set; get; }
    public string SeoDescription { set; get; }
    public string SeoTitle { set; get; }

    public string SeoAlias { get; set; }
    public string LanguageId { set; get; }

    public IFormFile ThumbnailImage { get; set; }
 }