任何人都可以告訴我有關如何避免使用代碼優先方法將某些屬性從模型映射到表?避免將屬性映射到表
例子:
public class Post
{
[Key]
public int Id { get; set; }
[Display(Name = "Posted")]
public DateTime Created { get; set; }
[Display(Name = "Modified")]
public DateTime? Modified { get; set; }
[Required]
[MaxLength(256)]
public string Title { get; set; }
[Required]
public string Body { get; set; }
public int? UserId { get; set; }
public string UserName { get; set; }
public virtual ICollection<Comment> Comments { get; set; }
public virtual ICollection<Tag> Tags { get; set; }
}
我想用戶名不映射到表。 EF有可能或不可以?
對不起! – Vengrovskyi