This question already has an answer here:
Entity Framework Code First will auto-create a table in the database base based on the Model.
Is there an attribute that will avoid this?
This question already has an answer here:
Entity Framework Code First will auto-create a table in the database base based on the Model.
Is there an attribute that will avoid this?
Per the accepted answer and similar question/answer, in addition to
[NotMapped]
you can also specify it using the Fluent API:[NotMapped]
is the short version if you like conciseness. And of course, you would add:to your class.
Add the
[System.ComponentModel.DataAnnotations.Schema.NotMapped]
attribute to the property.