Mapping to an existing schema
Quino is a metadata-first framework. The standard way of creating metadata is to create it using the modeling API in C#.
Quino derives the names of the database-schema elements from the names of various elements of the metadata. An application can control this mapping with the
ISchemaIdentifierBuilderSettings, which, in turn, use the low-level
Consider the following class with a single property in a model named
Elements.Person = Elements.Module .AddClass(nameof(Elements.Person)); Elements.Person .AddProperty("FirstName", MetaType.Text);
Person class maps to the table
FirstName property of that class maps to
- What if an application wants to build a model that maps to an existing database schema?
- That is, what if the table and column name are already defined in a legacy database, but the application would still like to map a model onto it?
- Can the application define the model using a different naming scheme?
FirstName property above should map to
tblPerson.Vorname. We extend the code above as follows.
Elements.Person = Elements.Module .AddClass(nameof(Elements.Person)) .SetSchemaIdentifier("tblPerson"); Elements.Person .AddProperty("FirstName", MetaType.Text) .SetSchemaIdentifier("Vorname");
Instead of automatically calculating its own schema identifiers, Quino uses the ones assigned in the model.