'Using { get; init; } autoproperty with Entity Framework Core

Entity Framework Core 6, .NET 6, C# 10

I've created a model class with some { get; init; } auto-implemented properties, to prevent someone (even myself) from accidentally changing their values in the code.

I made properties { get; init; } with in mind to never ever change those properties in the future, even on client's demand (Bad UX, sorry).

namespace MyApp.Models;

public class Employee
{
    public ulong Id { get; init; } // <-- 
    public string? Name { get; set; }
    public Gender Gender { get; init; } // <--
    public DateOnly DateOfBirth { get; init; } // <--
}

public enum Gender : byte
{
    Unspecified = 0,
    Male,
    Female
}

The question is: will it wreak havoc somewhere with EF? Is using { get; init; } in EF safe?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source