After upgrade from EF 2.0 to 2.1 we found that new migration recreates FKs and indexes in some strange manner shrinking their names to 63 chars. Also, the MaxIdentifierLength attribute was present in the top of migration file. I made some research and did not find how to configure that length default.
Currently there is no fluent API for that.
But it can be accessed via RelationalModelAnnotations class:
var maxIdentifierLength = modelBuilder.Model.Relational().MaxIdentifierLength;
It can also be modified:
modelBuilder.Model.Relational().MaxIdentifierLength = newValue;
but I won't recommend that. Each db provider sets by default the maximum supported identifier length (for SqlServer it's 128), hence configuring greater value will probably lead to invalid table / constraint names and runtime exceptions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With