问题遇到的现象和发生背景
没办法限定年龄(int类型)和体温(float类型)的长度
问题相关代码,请勿粘贴截图
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Mvcwork.Models
{
public class work
{
public int Id { get; set; } //id
[Display(Name = "姓名")]
[StringLength(300)]
public string? Name { get; set; } //姓名(长度不超过三百)
[Display(Name = "性别")]
[StringLength(1)]
public string? Gender { get; set; } //性别(长度为1)
[Display(Name = "年龄")]
//
public int Age { get; set; } //年龄(1-200)
//[Column(TypeName = "int(1, 200)")]
[Display(Name = "出生日期")]
[DataType(DataType.Date)]
public DateTime Birthday { get; set; } //出生日期
[Display(Name = "手机")]
[StringLength(13)]
public string? Phone { get; set; }//手机(13位)
[Display(Name = "体温")]
//[Column(TypeName = "float(30, 50)")]
[Precision(30, 50)]
public float Temperature { get; set; } //体温(30-50)
//[Display(Name = "填表日期")]
[DataType(DataType.Date)]
public DateTime TableDate { get; set; } //填表日期
}
}