【问题标题】:Using Data Annotations for SQLite in Entity Framework Core在 Entity Framework Core 中为 SQLite 使用数据注释
【发布时间】:2018-08-02 16:15:23
【问题描述】:

我正在使用 Entity Framework Core 来连接我的 SQLite 数据库。我想在我的模型Station 中为字段ExitSide 设置最小和最大范围:

using System.ComponentModel.DataAnnotations;
...
class Station
{
    public int StationId { get; set; }
    [Range(0,2)]
    public int ExitSide { get; set; }
}

但不知何故,它似​​乎被忽略了。例如,我仍然可以使用ExitSide=5 创建Stations。我做错了什么?

【问题讨论】:

  • 不应该像`[Range(0,2)]`吗?

标签: c# sqlite entity-framework-core


【解决方案1】:

EF Core 当前无法识别 Range 数据注释

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-09
    • 2020-01-30
    • 1970-01-01
    • 1970-01-01
    • 2016-10-25
    • 2017-10-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多