7
I need to enter a property in the model class, but when I enter the code first, it says the table already exists and changes have been made.
My code:
public class Data
{
[Key]
public int Id { get; set; }
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}")]
public Nullable<System.DateTime> Date { get; set; }
//public bool Selected { get; set; }
public virtual ICollection<Comment> Comments { get; set; }
}
If I uncheck the Selected property it gives this error:
The model backing the 'Context' context has changed Since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/? Linkid=238269).
Can I mark this property not to generate in the bank?
You have to migrate in order to change a
model
. New to Asp mvc?– CesarMiguel
Try to use the annotation
[NotMapped]
on the property.– Andre Calil
[NotMapped]
works for calculated field, that’s what he wants?– CesarMiguel