指数超出范围。插入 EF Core 后

Alo*_*ras 5 postgresql entity-framework-core

我正在使用 EF Core 来处理我的数据库,并且我想将一条记录插入到我的 postgresql 数据库中。

但是当我插入记录并保存更改时,应用程序会抛出错误:

指数超出范围。必须为非负数且小于集合的大小。(参数“索引”)

我知道当我使用集合时可能会出现此错误,但在本例中我正在执行插入。

我的基本实体:

public abstract class BaseEntity: IBaseEntity<long>
{
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    [Key, Column("id", Order = 0)]
    public long Id { get; set; }

    [Column("createdAt")]
    [DatabaseGenerated(DatabaseGeneratedOption.Computed)]
    public DateTime CreatedAt{ get; set; }

}
Run Code Online (Sandbox Code Playgroud)

从业务层插入:

  var entityToInsert = new Delivery()
  { 
       State = 1, //active
       Date = DateTime.Now,
  };

  await this.UOW.Delivery.CreateAsync(entityToInsert);
  await this.UOW.SaveChangesAsync();
Run Code Online (Sandbox Code Playgroud)

我的通用存储库方法:

    public async Task<TEntity> CreateAsync(TEntity entity)
    {
        await Context.AddAsync<TEntity>(entity);
        return entity;
    }
Run Code Online (Sandbox Code Playgroud)

交货表定义:

id         bigint // type identity "by default" autoincrment 1 per 1
state      integer 
date       timestamp without time zone  (not null)
createdAt  timestamp without time zone  (not null)
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?