ASP.NetCore - RuntimeBinderException:以下方法或属性之间的调用不明确

时间:2017-10-09 04:28:58

标签: c# asp.net asp.net-mvc asp.net-core asp.net-core-mvc

我正在使用ASP.Net Core 1.1。我的模型是这样的 -

public class JobCircular
{
    [Key]
    public UInt64 Id { get; set; }

    public string Name { get; set; }
    public string Detail { get; set; }
    [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd HH:mm:ss.S}", ApplyFormatInEditMode = true)]
    [DataType(DataType.Date)]
    public DateTime StartDate { get; set; }
    [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd HH:mm:ss.S}", ApplyFormatInEditMode = true)]
    [DataType(DataType.Date)]
    public DateTime EndDate { get; set; }

    [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd HH:mm:ss.S}", ApplyFormatInEditMode = true)]
    [DataType(DataType.Date)]
    public DateTime AddedDate { get; set; }

    [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd HH:mm:ss.S}", ApplyFormatInEditMode = true)]
    [DataType(DataType.Date)]
    public DateTime LastModifiedDate { get; set; }

    public DbSet<Teacher> Teachers { get; set; }

    public JobCircular()
    {
        AddedDate = DateTime.UtcNow;
        LastModifiedDate = DateTime.UtcNow;
    }
}

我的DBModel数据库是这样的 -

enter image description here

我在控制器中这样做 -

using (var context = new ApplicationDbContext())
{
    Random rnd = new Random();
    UInt16 year = (UInt16)rnd.Next(1999, 2017);

    var jobCircular1 = context.JobCirculars;

    JobCircular jobCircular = context.JobCirculars
                                .SingleOrDefault(j => j.Id == 1);

    ...........................
    ...........................
}

我收到了这个错误 -

An unhandled exception occurred while processing the request.

RuntimeBinderException: The call is ambiguous between the following methods or properties: 'Microsoft.EntityFrameworkCore.Storage.RelationalSqlGenerationHelper.GenerateLiteralValue(float)' and 'Microsoft.EntityFrameworkCore.Storage.RelationalSqlGenerationHelper.GenerateLiteralValue(decimal)'
CallSite.Target(Closure , CallSite , RelationalSqlGenerationHelper , object )

任何人都可以帮助我,我做错了吗?

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

原因是因为Unsigned Int 64在实体框架中不支持 (如第6页所述)。使用映射到SQL Long的{​​{1}}代替UInt64

请参阅Conversion Table

bigint