In all of the previous examples we have shown ‘Named” attributes specified with the form “EntityPropertyNames.{PropertyName}. This is a recommended pattern that ensures type safety. However, the following two attribute specifications have exactly the same effect:
C# | [BeforeSet(EntityPropertyNames.FirstName)] // or [BeforeSet("FirstName")] |
VB | <BeforeSet(EntityPropertyNames.FirstName)> ' or <BeforeSet("FirstName")> |
The ‘EntityPropertyNames’ reference is to a class that is generated (as multiple partial classes) inside the designer code file associated with the EntityModel. Its primary purpose is to allow specification of property names as constants. Note that because EntityPropertyNames is generated as a set of partial classes, you can add your own property names to the class for any custom properties that you create.