The [JsonIgnore]
attribute tells the JSON formatter to ignore the property during serialization but it is still part of the EF model and it still appears in the metadata generated from the DbContext
. Serialization and Metadata are distinct concerns.
You can hide it from metadata by adding the EDM [NotMapped]
attribute to the property in your model.
If you don't want to touch your model, you can tell EF to ignore it via Fluent Configuration in your DbContext
, e.g,
modelBuilder.Entity<Customer>().Ignore(t => t.CustomerID_OLD);
If you need that property to be accessible in server logic but hidden from Breeze metadata, you can create a dedicated MetadataDbContext
that inherits from your working DbContext
and put the "ignore" code in there. See the NorthwindMetadataContext
in DocCode for an example.
Reminder: In general, you can only hide nullable properties from EF. This will work in your case because the non-nullable property has a default value defined in the database schema. Otherwise, the database would reject inserts.