Setting Properties in Constructor

Starting from version 2.1, Entity Framework Core allows defining a parametrized constructor for a class and calls this constructor when creating a class instance.

Entity Developer allows adding parameters to such a constructor for assigning property values in the constructor when reading data from the database instead of calling a parameterless constructor and then assigning properties via their setters. This allows you, for example, to use read-only properties with private setters.

To add a parameter for a property to the constructor, simply set its Constructor Parameter property to True in the Properties window.

ExpandedToggleIcon        See Also


Send feedback on this topic

© 2008 - 2024 Devart. All rights reserved.