1

I have a need to email our DBA when a deployment, that utilizes EF6 code-based migrations, goes out. I am able to use the migrate.exe tool with the verbose flag, through powershell, to get the scripts but each command is truncated after 10222 characters. This usually only effects the model hash for the migrationHistory. Does anyone know of a way to generate the full sql script for EF6 migrations through Powershell

thanks T

1 Answer 1

1

Figured out that migrate.exe is wrapping the toolingfacade class So I created the object passing in the required variables as well as setting the verbosedelegate. The nice thing about this is that I could run the updatescript function instead if I just wanted to get the sql scripts

[Reflection.Assembly]::LoadFrom("EntityFramework.dll") | Out-Null
$con = New-Object -TypeName System.Data.Entity.Infrastructure.DbConnectionInfo -ArgumentList @("constring", "System.Data.SqlClient")
$tools = New-Object -TypeName System.Data.Entity.Migrations.Design.ToolingFacade -ArgumentList @("dbcondllname", "dbcondllname",$null,"workingdr",$null,$null,$con)
$tools.LogVerboseDelegate = {param($sql)
    Write-Verbose $sql -verbose #dumps the sql to RM log
}
$tools.Update($null,$false)
Sign up to request clarification or add additional context in comments.

4 Comments

any change you can clarify what is dbcondllname?
dbcondllname is the dll name that the db context residues in, I believe the second argument is where the migrations are stored which for this case was the same dll
Here is the link to the class constructor for more clarity. ToolingFacade
There is also $tools.ScriptUpdate. If you call Update it also applies the migration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.