Component Tables - HomeroThompson/firehawk GitHub Wiki

Component Tables

When components are mapped to a separate table (one-to-many relationships) Firehawk lets you choose the convention that will generate the names for these tables. It is recommended to customize component table names since many entities can use the same value object class and it could lead to name collisions if we left the table name be the same as the component name.

This is the available set of conventions:

ComponentName

The table name is generated based on the component name. This convention could generate non unique names if there are several entities that reference the same component class.

.ConfigureDomainModelConventions()
    .UseConventionForComponentTableNames(ComponentsTableNamingConvention.ComponentName)
.EndConfig()

Example Let's suppose that we have a Customer entity with a list of Phone value objects.

public class Customer
{
    public virtual long ID { get; set; }
    public virtual string Name { get; set; }
    public virtual IReadOnlyCollection<Phone> Phones {get; private set;}
}

public class Phone
{
    public virtual string Number { get; protected set; }
    public virtual TelephoneType Type { get; protected set; }
}

For the Phone component, Firehawk will generate a table name like this:

Phone
EntityNameComponentName

The table name is generated based on the entity name and component name. This convention avoids duplicated names when several entities reference the same component class.

.ConfigureDomainModelConventions()
    .UseConventionForComponentTableNames(ComponentsTableNamingConvention.EntityNameComponentName)
.EndConfig()

Example For the Phone component, Firehawk will generate a table name like this:

CustomerPhone
EntityName_ComponentName

The table name is generated based on the entity name and component name. This convention avoids duplicated names when several entities reference the same component class.

.ConfigureDomainModelConventions()
    .UseConventionForComponentTableNames(ComponentsTableNamingConvention.EntityName_ComponentName)
.EndConfig()

Example For the Phone component, Firehawk will generate a table name like this:

Customer_Phone
RelationshipName

The name is generated based on the name of the relationship between the entity and the component. Again, this convention could generate repeated names if there are several entities making reference to different components with the same relationship name.

.ConfigureDomainModelConventions()
    .UseConventionForComponentTableNames(ComponentsTableNamingConvention.RelationshipName)
.EndConfig()

Example For the Phone component, Firehawk will generate a table name like this:

Phones
EntityNameRelationshipName

The component table name is generated based on the entity name and the relationship name. This convention avoids duplicated tables names.

.ConfigureDomainModelConventions()
    .UseConventionForComponentTableNames(ComponentsTableNamingConvention.EntityNameRelationshipName)
.EndConfig()

Example For the Phone component, Firehawk will generate a table name like this:

CustomerPhones
EntityName_RelationshipName

The component table name is generated based on the entity name and the relationship name. This convention avoids duplicated tables names.

.ConfigureDomainModelConventions()
    .UseConventionForComponentTableNames(ComponentsTableNamingConvention.EntityNameRelationshipName)
.EndConfig()

Example For the Phone component, Firehawk will generate a table name like this:

Customer_Phones
Custom

The component table name is generated by an user defined function. This functions receives as input parameters the Entity Type, the Component Type and the entity's ID property name.

.ConfigureDomainModelConventions()
    .UseCustomConventionForComponentTableNames((e,c,i) =>
    {

    })
.EndConfig()
⚠️ **GitHub.com Fallback** ⚠️