Name Attribute
To understand this attribute, make sure you read about the Id attribute first.
The name attribute is a way to override the Id attribute defined by the design module. You would most commonly do that to avoid name conflicts with your engine's built-in types.
The name attribute is not visible in the design module. Hence, you need to switch to an engine to see and possibly change the name attribute. Just like the Id attribute, there are two places where you can find the name attribute.
- Entity Name - to customize the Entity Id
- Class Property Name - to customize a property Id
Name collision example
Let's say you create Date
class in your design module. Later you would decide to add
Swift engine to your project. You would encounter a problem after the Swift
code generation because there is a built-in Date
struct in Swift. To solve this,
you would switch to your Swift engine in OneGen app and set the name attribute to MyDate
for instance.
Other use cases
You may want to company-prefix your entities or just rename a single property to give it a natural feel in a particular engine. The decision is yours.
Name attributes are meant to solve a problem in a particular engine. If you find yourself in a situation where you'd need to change a name attribute in multiple engines, it might be better to change the Id attribute in the design module.
Empty by default
The name attribute is omitted if left out empty. It's also empty by default.