MVC3: Attribute for not mapping a property to a DB column

前端 未结 2 1640
盖世英雄少女心
盖世英雄少女心 2021-01-17 09:47

I’m using ASP.NET MVC3. I have a model that has one property that I don’t want to store in the database. Is there an attribute that I can put on the property to achieve this

2条回答
  •  余生分开走
    2021-01-17 10:17

    public class Person
    {
        [Key]
        public int Id { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
    
        [NotMapped]
        public string FullName { get; set; }
    }
    

    The attribute are in the namespace System.ComponentModel.DataAnnotations

提交回复
热议问题