Specify EF Core column/field as read only

The EF Core intended way is to set AfterSaveBehavior property to value other than the default Save:

Gets a value indicating whether or not this property can be modified after the entity is saved to the database.

If Throw, then an exception will be thrown if a new value is assigned to this property after the entity exists in the database.

If Ignore, then any modification to the property value of an entity that already exists in the database will be ignored.

There is no dedicated fluent API yet, so you need to set it directly through mutable property metadata like this:

entity.Property(e => e.DateCreated)
    .HasDefaultValueSql("(getdate())")
    .Metadata.AfterSaveBehavior = PropertySaveBehavior.Throw; // <-- 

Update (EF Core 3.x): Starting with EF Core 3.0, many properties like this have been replaced with Get / Set extension method pairs, so the relevant code now is as follows:

    .Metadata.SetAfterSaveBehavior(PropertySaveBehavior.Throw);