Search code examples
c#.netentity-frameworkentity-framework-4ef4-code-only

How not persist property EF4 code first?


How do I make non persisted properties using codefirst EF4?

MS says there is a StoreIgnore Attribute, but I cannot find it.

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

Is there a way to set this up using EntityConfiguration?


Solution

  • In EF Code-First CTP5, you can use the [NotMapped] annotation.

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