Code First Migrations Help

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
zlipps
Posts: 1
Joined: Thu 05 Mar 2015 14:23

Code First Migrations Help

Post by 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,

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Code First Migrations Help

Post by 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/postgr ... tions.html. The way how it can be applied is described at http://www.devart.com/dotconnect/postgr ... ation.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/1154 ... tion-ef5rc. You can vote for the corresponding suggestion: http://data.uservoice.com/forums/72025- ... de-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?

Post Reply