首页 > 解决方案 > Find' 的类型为 'int',与 'long' 的属性类型不匹配

问题描述

实体。

[Table("OrderLines", Schema = "Sales")]

    public class OrderLine
    {
        [Key]
        public long OrderLineID { get; set; }
    }

尝试通过 ID 获取实体

public virtual async Task<T> GetByIdAsync(object id)
{
    if (id == null) throw new ArgumentNullException("Identifier is null");
    return await _entities.FindAsync(id);
}

得到一个错误 System.AggregateException:“发生了一个或多个错误。(对'DbSet.Find'的调用位置0处的键值是'int'类型,与'long'的属性类型不匹配。) "

标签: ef-core-2.0

解决方案


推荐阅读