N Rocking
N Rocking

Reputation: 3035

Model property not to be mapped with the database table in MVC4

I am trying a model property not to be mapped with the database table. I've found a solution for fluent API which is

modelBuilder.Entity<MODEL_NAME>().Ignore(t => t.PROPERTY_NAME);

I am wondering whether there is any equivalent data annotations for that. E.g. the following one

modelBuilder.Entity<MODEL_NAME>().Property(t => t.PROPERTY_NAME).IsRequired();

can be written as

[Required]
public string PROPERTY_NAME{ get; set; }

Upvotes: 0

Views: 107

Answers (1)

Matt Millican
Matt Millican

Reputation: 4054

You can use the [NotMapped] attribute

Upvotes: 2

Related Questions