It is not possible to make objects truly immutable, but you can use an inaccessible setter so that users cannot modify them, which can be good enough, depending on your situation:
public string Address1 // Public Property without a Setter { get { return _address1; } internal set { _address1 = value; } }
The Entity Framework will still be able to set the value, so it will load correctly, but after creation, the property will be more or less fixed.
(I recommend using the internal installer rather than private , so you can still map to the Fluent API in your context or configuration class, provided that they are in the same assembly or friends assembly.)
source share