//文章 [Table("ArticleTB")] public class ArticleTB : BaseModelWithName { [Key] public int ID { get; set; } public ArticleTB() : base() { } public string Content { get; set; } public int CompanyID { get; set; } public int UserID { get; set; } [NotMapped] public UserTB UserTB { get; set; } }
完整的Data Annotations包括:(详细见 https://msdn.microsoft.com/en-us/library/jj193542(v=vs.113).aspx 第6部分)
KeyAttribute
StringLengthAttribute
MaxLengthAttribute
ConcurrencyCheckAttribute
RequiredAttribute
TimestampAttribute
ComplexTypeAttribute
ColumnAttribute
TableAttribute
InversePropertyAttribute
ForeignKeyAttribute
DatabaseGeneratedAttribute
NotMappedAttribute