Page 1 of 1

Setting Package Manager console migration options

Posted: Wed 10 Oct 2012 05:02
by andyb0070
My environment is as follows:

Visual Studion 2010
Entity Framework 5
Devart DotConnect: 7.2.96.0
Oracle 11g

I'm attempting to upgrade my database using the Package Manger console command:

PM> Update-Database -Verbose -ConnectionStringName "SID1"

This references the app.config <connectionStrings> section to obtain the connection string. However, migration then throws an exception: "System.InvalidOperationException: Foreign key name 'FK_USERPROFILE_ADDRESS_ADDRESSID' in table USERPROFILE is too long (32 characters). An identifier with more than 30 characters was specified."

I see that I can set some options like "CodeFirstOptions.TruncateLongDefaultNames = True" but how would I do this when using the PM console?

Re: Setting Package Manager console migration options

Posted: Thu 11 Oct 2012 12:48
by Shalex
andyb0070 wrote:I see that I can set some options like "CodeFirstOptions.TruncateLongDefaultNames = True" but how would I do this when using the PM console?
Please set this option in the static constructor of your DbContext descendant and it will be taken into accout when you apply migrations via PM console.