Mapping to an existing Schema (DB-First)

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 ISchemaIdentifierBuilder and ISchemaIdentifierBuilderSettings, which, in turn, use the low-level IIdentifierTransformer and IIdentifierBuilder.

Consider the following class with a single property in a model named Punchclock.

Elements.Person = Builder.Add.Class(nameof(Elements.Person)); Elements.Person.Add.Property("FirstName", MetaType.Text);
  • 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?

Suppose the FirstName property above should map to tblPerson.Vorname. We extend the code above as follows.

Elements.Person = Builder.Add.Class(nameof(Elements.Person)).Table("tblPerson"); Elements.Person .Add .Property("FirstName", MetaType.Text) .Column("Vorname");

Instead of automatically calculating its own schema identifiers, Quino uses the ones assigned in the model.