【发布时间】:2017-10-09 12:42:10
【问题描述】:
我正在使用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 数据库是这样的-
我正在控制器中执行此操作-
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 )
谁能帮我解决我做错了什么?
提前感谢您的帮助。
【问题讨论】:
-
看看这个类似的问题:github.com/aspnet/EntityFrameworkCore/issues/8259。似乎这是一个 EF Core 库问题。
-
在这种情况下,我该怎么办? @TetsuyaYamamoto
标签: c# asp.net asp.net-mvc asp.net-core asp.net-core-mvc