简体   繁体   English

在Entity Framework Core中为SQLite使用数据注释

[英]Using Data Annotations for SQLite in Entity Framework Core

I am using the Entity Framework Core to interface my SQLite database. 我正在使用Entity Framework Core来连接我的SQLite数据库。 I want to set a minimum and maximum range for the field ExitSide in my model Station : 我想在模型Station为字段ExitSide设置最小和最大范围:

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

But somehow it seems to get ignored. 但是它似乎以某种方式被忽略了。 I am still able to create Stations with ExitSide=5 for example. 例如,我仍然可以使用ExitSide=5创建Stations What am I doing wrong? 我究竟做错了什么?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM