zoukankan      html  css  js  c++  java
  • Entity Framework Core 3.1 学习笔记2 设定字段属性

    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations.Schema;
    
    namespace Demo.Domain
    {
        public class Club
        {
            public Club() {
                Players = new List<Player>();
            }
    
            public int Id { get; set; }
    
            public string Name { get; set; }
    
    
            public string City { get; set; }
    
            [Column(TypeName ="date")]
            public DateTime DateOffEstablishment { get; set; }
    
            public string History { get; set; }
    
            public League League { get; set; }
    
            public List<Player> Players { get; set; }
        }
    }
    

      

    using System.ComponentModel.DataAnnotations;
    
    namespace Demo.Domain
    {
        public class League
        {
            public int Id { get; set; }
    
            [Required]
            [MaxLength(100)]
            public string Name { get; set; }
    
            [Required,MaxLength(50)]
            public string Country { get; set; }
        }
    }
    

      

    Nuget包:

        <PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />

  • 相关阅读:
    1924班网址
    20192414《网络空间安全导论》第一周学习总结
    H-Angry
    A-Plague Inc
    B-Rolling The Polygon
    F-Moving On
    A-Maximum Element In A Stack
    J-Word Search
    E-Pawns
    D-Lift Problems
  • 原文地址:https://www.cnblogs.com/tofight/p/14644888.html
Copyright © 2011-2022 走看看