Can't run code first migrations using migrate.exe

元气小坏坏 提交于 2019-11-28 23:22:54

Finally got this to work with Entity framework 6.1.3. I'm not sure if the version really matters, but we ended up downloading the code and debugging against that.

What really made the difference was using the full path in both of the paths required... Hope that can help someone!

migrate CodeFirst.dll Configuration /startUpDirectory:"C:\src\app\CodeFirst\bin\Debug" /startUpConfigurationFile:"C:\src\app\CodeFirst\bin\CodeFirst.dll.config" 

I reached out to the EF team, and apparently things will be better in EF7: https://github.com/aspnet/EntityFramework/issues/2974

Those of us just starting to use this tool might find this PowerShell script useful - it contains some default values for some common use cases:

Param(
    [string]$DbConnectionString,
    [string]$StartUpDirectory,
    [string]$DataModelDllName,
    [string]$StartUpConfigurationFile = "$StartUpDirectory\$DataModelDllName.config",
    [string]$ConfigurationClassName = "Configuration",
    [string]$ConnectionProviderName = "System.Data.SqlClient",
    [string]$MigrateToolPath = "$PSScriptRoot\migrate.exe"
)

& $MigrateToolPath $DataModelDllName $ConfigurationClassName /startUpConfigurationFile=$StartUpConfigurationFile /connectionString=$DbConnectionString /connectionProviderName=$ConnectionProviderName  /startUpDirectory=$StartUpDirectory
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!