Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude properties for migrations [duplicate]

I have properties on my model that I don't want to generate fields in the tables after a migration.

Is it possible to exclude properties for Entity Framework Core migrations?

Is there an attribute for the model or some Fluent API method on my DbContext for this?

like image 413
Alpha75 Avatar asked Oct 12 '25 20:10

Alpha75


1 Answers

You should be able to specify [NotMapped] as a data annotation above the property.

E.g. if you wanted to have FullName in your model which consisted of FirstName and LastName you would do:

public string FirstName { get; set; }
public string LastName { get; set; }

[NotMapped]
public string FullName { get;set };
like image 186
SashaStojanovic Avatar answered Oct 14 '25 08:10

SashaStojanovic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!