Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
1

You could remove validation from the constructor, make the constructor internal, and call it from the repository to allow unvalidated object creation. If the repository is in a separate assembly, use https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.internalsvisibletoattribute?view=netframework-4.8 Next add a public static factory ...


Only top voted, non community-wiki answers of a minimum length are eligible