相关疑难解决方法(0)

使用Entity Framework保存对SQL Server数据库的更改时,一个或多个实体的验证失败

我想保存我的编辑到数据库,我在ASP.NET MVC 3/C#中使用实体框架代码优先,但我收到错误.在我的Event类中,我有DateTime和TimeSpan数据类型,但在我的数据库中,我分别有日期和时间.这可能是原因吗?在保存对数据库的更改之前,如何在代码中转换为适当的数据类型.

public class Event
{
    public int EventId { get; set; }
    public int CategoryId { get; set; }
    public int PlaceId { get; set; }
    public string Title { get; set; }
    public decimal Price { get; set; }
    public DateTime EventDate { get; set; }
    public TimeSpan StartTime { get; set; }
    public TimeSpan EndTime { get; set; }
    public string Description { get; set; }
    public string EventPlaceUrl { get; set; }
    public Category Category …
Run Code Online (Sandbox Code Playgroud)

c# sql asp.net-mvc entity-framework code-first

333
推荐指数
6
解决办法
31万
查看次数

标签 统计

asp.net-mvc ×1

c# ×1

code-first ×1

entity-framework ×1

sql ×1