Code First Migrations Help

Code First Migrations Help

Postby zlipps » Thu 05 Mar 2015 16:14

We are using EF's code first migrations to update our database and I have ran into some issues with some edge cases and was wondering if there was currently any work around.

The main issues we are having are:
- The generated index names are too long
- The generated foreign key names are too long
- Not able to specify default values, default attribute is not picked up by the generator

I was not able to find any support for any of these other than modifying the generated migration classes, the issue with this is that if we delete the migration and regenerate it then all that work was lost, we have a rather large database the initial create of the database took over 6 hours to rename all the indexes and foreign keys.

I was hoping there is someway to extend the PgSqlEntityMigrationSqlGenerator class to be able to achieve this. I know these are all constraints with EF's migrations I was just wondering if there was a way to extend the SqlGenerator to include these features myself.

Thanks,
zlipps
 
Posts: 1
Joined: Thu 05 Mar 2015 14:23

Re: Code First Migrations Help

Postby Shalex » Fri 06 Mar 2015 15:40

zlipps wrote:The main issues we are having are:
- The generated index names are too long
- The generated foreign key names are too long

Please use the TruncateLongDefaultNames Code-First option. Its description: http://www.devart.com/dotconnect/postgresql/docs/?CodeFirstOptions.html. The way how it can be applied is described at http://www.devart.com/dotconnect/postgresql/docs/?EFProviderConfiguration.html.

zlipps wrote:- Not able to specify default values, default attribute is not picked up by the generator

Generator of code for EF Migrations is implemented by Microsoft:
http://stackoverflow.com/questions/11546295/entity-framework-migrations-dont-include-defaultvalue-data-annotation-ef5rc. You can vote for the corresponding suggestion: http://data.uservoice.com/forums/72025-entity-framework-feature-suggestions/suggestions/4783681--defaultvalue-is-not-handled-by-code-first-m.

JIC: if you are using pure Code-First Approach, why don't you want to specify a default value in the constructor of your class?
Shalex
Devart Team
 
Posts: 7774
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for PostgreSQL