4

We are using Entity Framework 4.3.1's migrate.exe tool to run database migrations from our TeamCity build server as part of our continuous integration and deployment automation. One of these issues we have been encountering is that the migrate.exe tool does not emit a non-zero exit code when it fails:

C:\<path>\packages\EntityFramework.4.3.1\tools>migrate.exe AppContext /startupdirectory:C:\<path>\bin\Debug /startupconfigurationfile:C:\<path>\Web.config /verbose
<Bunch of successful migrations>
Applying explicit migration: 201202212004585_UpdateTable
VERBOSE: ALTER TABLE [TableA] DROP CONSTRAINT [FK_TableA_TableB]
System.Data.Entity.Migrations.Design.ToolingException: 'FK_TableA_TableB' is not a constraint.
Could not drop constraint. See previous errors.
   at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
   at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMig
ration, Boolean force)
   at System.Data.Entity.Migrations.Console.Program.Run()
   at System.Data.Entity.Migrations.Console.Program.Main(String[] args)
ERROR: 'FK_TableA_TableB' is not a constraint.
Could not drop constraint. See previous errors.

C:\<path>\packages\EntityFramework.4.3.1\tools>echo %errorlevel%
0

This is causing Team City to pass a build off as "successful" when a migration fails and it should be failed.

Our temporary work-around is to grep the build log for "ERROR:" and fail the build when this occurs, but this solution is crude and we cannot tell if EF failed or some other process with a similar log entry.

Any suggestions for a better work around? Either a way to make migrate.exe behave or a way to get Team City understand that the failure is specific to migrate.exe.

jslatts
  • 9,307
  • 5
  • 35
  • 38
  • Link? I wasn't sure if it was considered to be incorrect behavior or not. – jslatts Apr 25 '12 at 17:33
  • Unfortunately the bug database is not public. I believe this is a bug - your scenario clearly shows that there is a value in distinguishing between error and non-error cases. – Pawel Apr 25 '12 at 18:07
  • This appears to exist again in v6.0.21010.0. – Mike Cole Nov 22 '13 at 23:06

2 Answers2

1

http://blogs.msdn.com/b/adonet/archive/2012/05/15/ef5-release-candidate-available-on-nuget.aspx

This release also includes fixes for the following bugs found in Beta 2:

  • ...
  • Migrations: Migrate.exe does not set error code after a failure
Pawel
  • 31,342
  • 4
  • 73
  • 104
  • This appears to exist again in v6.0.21010.0. – Mike Cole Nov 22 '13 at 23:06
  • 1
    @MikeCole thanks for reporting - created a workitem for this: https://entityframework.codeplex.com/workitem/1859 – Pawel Nov 23 '13 at 00:41
  • 1
    @MikeCole - a fix for EF6 has just been checked in (https://entityframework.codeplex.com/SourceControl/changeset/5ed07059bcae71b39dce14d0b3ee6ba62de9a188). Note that it did not make into EF6.1-alpha that shipped earlier today but should be included in next releases. – Pawel Dec 20 '13 at 18:20
  • This still doesn't appear to be in 6.0.2. Is that that case? If so, do you know when it may be released? – Mike Cole Mar 05 '14 at 18:01
  • @MikeCole - if you look at the bug there is a Release field which points to the release a bug is being fixed. In this case it is 6.1.0 – Pawel Mar 05 '14 at 18:41
1

This bug was fixed in EF 5 RC: - Using a login that has a default schema other than ‘dbo’ for the user causes runtime failures

ITmeze
  • 1,902
  • 2
  • 21
  • 32