EF Code first NotMapped Attribute

Viewed 15730

Why is in the following example the [NotMapped] attribute required:

public virtual ICollection<Blog> Blogs { get; set; }

[NotMapped]
    public List<Blog> NewBlogs{
        get{
            return Blogs.Where(x=>x.Date > DateTime.Now).ToList();
        }
    }

Without the [NotMapped] attribute I get an exception:

Invalid column name Blog_ID

The column name in the database is BlogID.

EDIT

I would expect, that properties without setter are never directly mapped to the database and automatically ignored by code first.

3 Answers
Related