I have an Entity Framework Code First model with a column that is not mapped which I still want to persist between the server and the client. The model looks similar to this with many more properties:
public class OwnerInformation
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Required]
[MaxLength(16)]
public byte[] SSNEncrypted { get; set; }
[NotMapped]
[MaxLength(9)]
[MinLength(9)]
public string SSN { get; set; }
}
When the metadata is retrieved by Breeze SSN is not part of it, but when the data is sent over the wire the SSN is there. I would like to let breeze deal with the mapping through the metadata, but I would like to be able to still pass SSN between the client and the server and track it's state as I need to encrypt it before it is saved to the DB.
I tried adding it after the metadata is fetched like this:
var ownerType = manager.metadataStore.getEntityType('OwnerInformation');
var sSN = new breeze.DataProperty({
name: 'sSN',
dataType: breeze.DataType.String,
isNullable: false,
maxLength: 9
});
ownerType.addProperty(sSN);
but I get the error: The 'OwnerInformation:#Models' EntityType has already been added to a MetadataStore and therefore no additional properties may be added to it.
Maybe I'm overthinking this and there is an easier way. I'm opened to any suggestions.