Analyzing Entity Framework Code First default conventions
In my previous post I told the tale of how I used a wrong (but still awesome) tool to solve a problem. The problem was that I had not known the default conventions when using Entity Framework Code First.
To remedy this problem, I decided to take a look at the conventions runtime, generate the list of conventions and look at their source code at the Entity Framework Github repository.
So here's what I have found; might be useful for someone else too ;)
ModelNamespaceConvention | This convention uses the namespace of the derived class as the namespace of the conceptual model |
ForeignKeyPrimitivePropertyAttributeConvention | Convention to process instances of ForeignKeyAttribute found on foreign key properties in the model. |
InversePropertyAttributeConvention | Convention to process instances of InversePropertyAttribute found on navigation properties in the model. |
IndexAttributeConvention | Convention to process instances of IndexAttribute found on properties in the model. |
ColumnAttributeConvention | Convention to process instances of ColumnAttribute found on properties in the model. |
StringLengthAttributeConvention | Convention to process instances of StringLengthAttribute found on properties in the model. |
MaxLengthAttributeConvention | Convention to process instances of MaxLengthAttribute found on properties in the model. |
DatabaseGeneratedAttributeConvention | Convention to process instances of DatabaseGeneratedAttribute found on properties in the model. |
ConcurrencyCheckAttributeConvention | Convention to process instances of ConcurrencyCheckAttribute found on properties in the model. |
TimestampAttributeConvention | Convention to process instances of TimestampAttribute found on properties in the model. |
RequiredNavigationPropertyAttributeConvention | Convention to process instances of RequiredAttribute found on navigation properties in the model. |
RequiredPrimitivePropertyAttributeConvention | Convention to process instances of RequiredAttribute found on properties in the model. |
KeyAttributeConvention | Convention to process instances of KeyAttribute found on properties in the model. |
NotMappedPropertyAttributeConvention | Convention to process instances of NotMappedAttribute found on properties in the model. |
TableAttributeConvention | Convention to process instances of TableAttribute found on types in the model. |
ComplexTypeAttributeConvention | Convention to process instances of ComplexTypeAttribute found on types in the model. |
NotMappedTypeAttributeConvention | Convention to process instances of NotMappedTypeAttribute found on types in the model. |
IdKeyDiscoveryConvention | Finds the PK of every entity; derive and override MatchKeyProperty method to specify your own |
AssociationInverseDiscoveryConvention | Convention to detect navigation properties to be inverses of each other when only one pair of navigation properties exists between the related types |
ForeignKeyNavigationPropertyAttributeConvention | Convention to process instances of ForeignKeyAttribute found on navigation properties in the model. |
OneToOneConstraintIntroductionConvention | Convention to configure the primary key(s) of the dependent entity type as foreign key(s) in a one:one relationship. |
NavigationPropertyNameForeignKeyDiscoveryConvention | Convention to discover foreign key properties whose names are a combination of the dependent navigation property name and the principal type primary key property name(s). |
PrimaryKeyNameForeignKeyDiscoveryConvention | Convention to discover foreign key properties whose names match the principal type primary key property name(s). |
TypeNameForeignKeyDiscoveryConvention | Convention to discover foreign key properties whose names are a combination of the principal type name and the principal type primary key property name(s). |
ForeignKeyAssociationMultiplicityConvention | Convention to distinguish between optional and required relationships based on CLR nullability of the foreign key property. |
OneToManyCascadeDeleteConvention | Generates FKs with cascade delete for one-to-many relationships |
ComplexTypeDiscoveryConvention | Configures a type as a complex type if it has no primary key, no mapped base type and no navigation properties. |
StoreGeneratedIdentityKeyConvention | Adds the identity specification to int PKs |
PluralizingEntitySetNameConvention | Convention to set the entity set name to be a pluralized version of the entity type name. |
DeclaredPropertyOrderingConvention | Moves the PK to the top of the column list in tables |
SqlCePropertyMaxLengthConvention | Set a default length of 4000 for properties that support "length" if the provider is SqlCe |
PropertyMaxLengthConvention | Set a default length for string and binary types. If they are keys, a default length of 128 is applied, otherwise they are set to maxlength. |
DecimalPropertyConvention | Specifies the default precision of decimal (18,2). |
ModelContainerConvention | Uses the name of the DbContext as the container for the conceptual model |
ManyToManyCascadeDeleteConvention | Generates FKs with cascade delete for many-to-many relationships |
MappingInheritedPropertiesSupportConvention | Convention to ensure an invalid/unsupported mapping is not created when mapping inherited properties (i.e. an inherited property cannot be mapped to two different tables by two different derived types) |
PluralizingTableNameConvention | Convention to set the table name to be a pluralized version of the entity type name. |
ColumnOrderingConventionStrict | Generates the columns in order specified by the Column attribute; throws if two columns are specified the same values |
ForeignKeyIndexConvention | Creates a non-clustered index on FKs |