How not persist property EF4 code first?

Adam Bell picture Adam Bell · Aug 29, 2010 · Viewed 16.5k times · Source

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?

Answer

Matt Frear picture Matt Frear · Jan 1, 2011

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; }