-
Notifications
You must be signed in to change notification settings - Fork 7
Configuration Conventions
The ConfigurationBase and DefaultConfiguration classes, if you're extending them, allow you to specify an IConvention for mapping classes to tables.
string TableFor(Type entity);
string SchemaFor(Type entity);
string PrimaryKeyFor(Type entity, IEnumerable<string> propertyNames);
bool IsPrimaryKeyAutoGenerated(IColumn primaryKeyColumn);
ushort StringLengthFor(Type entity, string propertyName);
byte DecimalPrecisionFor(Type entity, string propertyName);
byte DecimalScaleFor(Type entity, string propertyName);
The default convention, cunningly named, "DefaultConvention" does the following:
Uses the PluralizationService from System.Data.Entity.Design.PluralizationServices (with an en-GB culture) to pluralize class names.
null (!!)
Selects the primary key by convention from the properties. Either FooId (where Foo is the class name), Id or ID by default.
If it's an int, long or guid then yes, otherwise no. If set to true for a particular table it's assumed the primary key is generated on insert, in which case the primary key is fetched after insert and set on the entity.
255
18
10
The last 3 can be provided via the DefaultConvention constructor.