Note: This documentation is a DRAFT.
A product that uses auto-generated meta-ids should use
GenerateMetaIdFrom() to improve automatic schema-migration.
A meta-id is used in schema/migration to uniquely identify a schema element, even if the name of that element has changed. When Quino migrates a database, it stores extra information in the
productname__schemaelementdescription table. Among other information, this table tells Quino which meta-id (Guid) to associate with each schema element (e.g. table, property, index, foreign key).
FallbackMetaIdBuilder ensures that every schema-relevant metadata has a meta-id. If one has not already been assigned, it uses the algorithm in the
IMetaIdCalculator to generate a MetaId. The default is to take the Guid of the parent and use the name of the metadata as "salt" to generate a unique, but stable MetaId.
This works great and allows a model to ignore meta-ids for the most part. However, once a product has been released, renaming a property or class changes the MetaId calculated for that element. That means that the next schema-migration will be sub-optimal: since Quino can't match up the new MetaId with the previous one, so it's forced to drop the old field or table and recreate it. This is almost certainly not what you want to be doing to a productive database.
To avoid this behavior, the developer has to attach the previously-generated MetaId (based on the old name) to the metadata instead. However, since the previous MetaId was automatically generated, the developer would have to dig it out of the schema table or somehow obtain it.
Quino offers a better way: call
GenerateMetaIdFrom() with the name that was used to generate the original MetaId.
Suppose the original model contained the following code:
To rename the property and ensure that it smoothly migrates, write the following:
Elements.Person .AddProperty("FirstName") .GenerateMetaIdFrom("Name");