【发布时间】: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