如何不先保留属性EF4代码?

Ada*_*ell 49 .net c# entity-framework entity-framework-4 ef4-code-only

如何使用codefirst EF4创建非持久属性?

MS说有一个StoreIgnore属性,但我找不到它.

http://blogs.msdn.com/b/efdesign/archive/2010/03/30/data-annotations-in-the-entity-framework-and-code-first.aspx

有没有办法使用EntityConfiguration设置它?

Mat*_*ear 62

在EF Code-First CTP5中,您可以使用[NotMapped]注释.

using System.ComponentModel.DataAnnotations;
public class Song
{
    public int Id { get; set; }
    public string Title { get; set; }

    [NotMapped]
    public int Track { get; set; }
Run Code Online (Sandbox Code Playgroud)

  • 我使用了`[System.ComponentModel.DataAnnotations.Schema.NotMapped]`,这似乎完成了这个伎俩. (7认同)