2
I am using EF6 and I have a problem using the command Update-Database -Verbose -Force. From the following error:
PM> Update-Database -Verbose -Force
Using StartUp project 'PersonalTrainer.Presentation'.
Using NuGet project 'PersonalTrainer.Infra.Data'.
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Target database is: 'TesteDb' (DataSource: PC-RAPHAEL\SQLEXPRESS, Provider: System.Data.SqlClient, Origin: Configuration).
No pending explicit migrations.
Applying automatic migration: 201607061619096_AutomaticMigration.
IF object_id(N'[dbo].[FK_dbo.Cliente_dbo.Endereco_EnderecoId]', N'F') IS NOT NULL
ALTER TABLE [dbo].[Cliente] DROP CONSTRAINT [FK_dbo.Cliente_dbo.Endereco_EnderecoId]
IF object_id(N'[dbo].[FK_dbo.Endereco_dbo.Cliente_Cliente_Id]', N'F') IS NOT NULL
ALTER TABLE [dbo].[Endereco] DROP CONSTRAINT [FK_dbo.Endereco_dbo.Cliente_Cliente_Id]
IF object_id(N'[dbo].[FK_dbo.ClienteAgenda_dbo.Cliente_ClienteId]', N'F') IS NOT NULL
ALTER TABLE [dbo].[ClienteAgenda] DROP CONSTRAINT [FK_dbo.ClienteAgenda_dbo.Cliente_ClienteId]
IF object_id(N'[dbo].[FK_dbo.Treino_dbo.Cliente_Cliente_Id]', N'F') IS NOT NULL
ALTER TABLE [dbo].[Treino] DROP CONSTRAINT [FK_dbo.Treino_dbo.Cliente_Cliente_Id]
IF object_id(N'[dbo].[FK_dbo.AnamneseAtividadeFisica_dbo.Cliente_Cliente_Id]', N'F') IS NOT NULL
ALTER TABLE [dbo].[AnamneseAtividadeFisica] DROP CONSTRAINT [FK_dbo.AnamneseAtividadeFisica_dbo.Cliente_Cliente_Id]
IF object_id(N'[dbo].[FK_dbo.AnamneseNutricional_dbo.Cliente_Cliente_Id]', N'F') IS NOT NULL
ALTER TABLE [dbo].[AnamneseNutricional] DROP CONSTRAINT [FK_dbo.AnamneseNutricional_dbo.Cliente_Cliente_Id]
IF object_id(N'[dbo].[FK_dbo.AnamneseGeral_dbo.Cliente_Cliente_Id]', N'F') IS NOT NULL
ALTER TABLE [dbo].[AnamneseGeral] DROP CONSTRAINT [FK_dbo.AnamneseGeral_dbo.Cliente_Cliente_Id]
IF object_id(N'[dbo].[FK_dbo.ComposicaoCorporal_dbo.Cliente_Cliente_Id]', N'F') IS NOT NULL
ALTER TABLE [dbo].[ComposicaoCorporal] DROP CONSTRAINT [FK_dbo.ComposicaoCorporal_dbo.Cliente_Cliente_Id]
IF object_id(N'[dbo].[FK_dbo.Financeiro_dbo.Cliente_Cliente_Id]', N'F') IS NOT NULL
ALTER TABLE [dbo].[Financeiro] DROP CONSTRAINT [FK_dbo.Financeiro_dbo.Cliente_Cliente_Id]
IF object_id(N'[dbo].[FK_dbo.Imc_dbo.Cliente_Cliente_Id]', N'F') IS NOT NULL
ALTER TABLE [dbo].[Imc] DROP CONSTRAINT [FK_dbo.Imc_dbo.Cliente_Cliente_Id]
IF object_id(N'[dbo].[FK_dbo.Parq_dbo.Cliente_Cliente_Id]', N'F') IS NOT NULL
ALTER TABLE [dbo].[Parq] DROP CONSTRAINT [FK_dbo.Parq_dbo.Cliente_Cliente_Id]
IF object_id(N'[dbo].[FK_dbo.Perimetria_dbo.Cliente_Cliente_Id]', N'F') IS NOT NULL
ALTER TABLE [dbo].[Perimetria] DROP CONSTRAINT [FK_dbo.Perimetria_dbo.Cliente_Cliente_Id]
IF object_id(N'[dbo].[FK_dbo.RiscoCardiaco_dbo.Cliente_Cliente_Id]', N'F') IS NOT NULL
ALTER TABLE [dbo].[RiscoCardiaco] DROP CONSTRAINT [FK_dbo.RiscoCardiaco_dbo.Cliente_Cliente_Id]
IF object_id(N'[dbo].[FK_dbo.Endereco_dbo.Cidade_Cidade_Id]', N'F') IS NOT NULL
ALTER TABLE [dbo].[Endereco] DROP CONSTRAINT [FK_dbo.Endereco_dbo.Cidade_Cidade_Id]
IF object_id(N'[dbo].[FK_dbo.Cidade_dbo.Estado_Estado_Id]', N'F') IS NOT NULL
ALTER TABLE [dbo].[Cidade] DROP CONSTRAINT [FK_dbo.Cidade_dbo.Estado_Estado_Id]
IF object_id(N'[dbo].[FK_dbo.ClienteAgenda_dbo.Agenda_AgendaId]', N'F') IS NOT NULL
ALTER TABLE [dbo].[ClienteAgenda] DROP CONSTRAINT [FK_dbo.ClienteAgenda_dbo.Agenda_AgendaId]
IF object_id(N'[dbo].[FK_dbo.TreinoAgenda_dbo.Agenda_AgendaId]', N'F') IS NOT NULL
ALTER TABLE [dbo].[TreinoAgenda] DROP CONSTRAINT [FK_dbo.TreinoAgenda_dbo.Agenda_AgendaId]
IF object_id(N'[dbo].[FK_dbo.TreinoAgenda_dbo.Treino_ClienteId]', N'F') IS NOT NULL
ALTER TABLE [dbo].[TreinoAgenda] DROP CONSTRAINT [FK_dbo.TreinoAgenda_dbo.Treino_ClienteId]
IF object_id(N'[dbo].[FK_dbo.AnamneseNutricional_dbo.Nutricionista_Nutricionista_Id]', N'F') IS NOT NULL
ALTER TABLE [dbo].[AnamneseNutricional] DROP CONSTRAINT [FK_dbo.AnamneseNutricional_dbo.Nutricionista_Nutricionista_Id]
IF EXISTS (SELECT name FROM sys.indexes WHERE name = N'IX_EnderecoId' AND object_id = object_id(N'[dbo].[Cliente]', N'U'))
DROP INDEX [IX_EnderecoId] ON [dbo].[Cliente]
EXECUTE sp_rename @objname = N'dbo.AnamneseAtividadeFisica.Cliente_Id', @newname = N'Cliente_ClienteId', @objtype = N'COLUMN'
Caution: Changing any part of an object name could break scripts and stored procedures.
EXECUTE sp_rename @objname = N'dbo.AnamneseNutricional.Cliente_Id', @newname = N'Cliente_ClienteId', @objtype = N'COLUMN'
EXECUTE sp_rename @objname = N'dbo.AnamneseGeral.Cliente_Id', @newname = N'Cliente_ClienteId', @objtype = N'COLUMN'
EXECUTE sp_rename @objname = N'dbo.ComposicaoCorporal.Cliente_Id', @newname = N'Cliente_ClienteId', @objtype = N'COLUMN'
EXECUTE sp_rename @objname = N'dbo.Financeiro.Cliente_Id', @newname = N'Cliente_ClienteId', @objtype = N'COLUMN'
EXECUTE sp_rename @objname = N'dbo.Imc.Cliente_Id', @newname = N'Cliente_ClienteId', @objtype = N'COLUMN'
EXECUTE sp_rename @objname = N'dbo.Parq.Cliente_Id', @newname = N'Cliente_ClienteId', @objtype = N'COLUMN'
EXECUTE sp_rename @objname = N'dbo.Perimetria.Cliente_Id', @newname = N'Cliente_ClienteId', @objtype = N'COLUMN'
EXECUTE sp_rename @objname = N'dbo.RiscoCardiaco.Cliente_Id', @newname = N'Cliente_ClienteId', @objtype = N'COLUMN'
EXECUTE sp_rename @objname = N'dbo.Endereco.Cidade_Id', @newname = N'Cidade_CidadeId', @objtype = N'COLUMN'
EXECUTE sp_rename @objname = N'dbo.Endereco.Cliente_Id', @newname = N'Cliente_ClienteId', @objtype = N'COLUMN'
System.Data.SqlClient.SqlException (0x80131904): Either the parameter @objname is ambiguous or the claimed @objtype (COLUMN) is wrong.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<NonQuery>b__0(DbCommand t, DbCommandInterceptionContext`1 c)
at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.NonQuery(DbCommand command, DbCommandInterceptionContext interceptionContext)
at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteNonQuery()
at System.Data.Entity.Migrations.DbMigrator.ExecuteSql(MigrationStatement migrationStatement, DbConnection connection, DbTransaction transaction, DbInterceptionContext interceptionContext)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ExecuteSql(MigrationStatement migrationStatement, DbConnection connection, DbTransaction transaction, DbInterceptionContext interceptionContext)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable`1 migrationStatements, DbConnection connection, DbTransaction transaction, DbInterceptionContext interceptionContext)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsWithinTransaction(IEnumerable`1 migrationStatements, DbTransaction transaction, DbInterceptionContext interceptionContext)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsWithinNewTransaction(IEnumerable`1 migrationStatements, DbConnection connection, DbInterceptionContext interceptionContext)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable`1 migrationStatements, DbConnection connection, DbInterceptionContext interceptionContext)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable`1 migrationStatements, DbConnection connection)
at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClass30.<ExecuteStatements>b__2e()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass1.<Execute>b__0()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action operation)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable`1 migrationStatements, DbTransaction existingTransaction)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable`1 migrationStatements)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.ExecuteStatements(IEnumerable`1 migrationStatements)
at System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String migrationId, VersionedModel targetModel, IEnumerable`1 operations, IEnumerable`1 systemOperations, Boolean downgrading, Boolean auto)
at System.Data.Entity.Migrations.DbMigrator.AutoMigrate(String migrationId, VersionedModel sourceModel, VersionedModel targetModel, Boolean downgrading)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.AutoMigrate(String migrationId, VersionedModel sourceModel, VersionedModel targetModel, Boolean downgrading)
at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration)
at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClassc.<Update>b__b()
at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration)
at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.Run()
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force)
at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
ClientConnectionId:d0dc8877-45a7-47c1-a868-1aca4f274208
Error Number:15248,State:1,Class:11
Either the parameter @objname is ambiguous or the claimed @objtype (COLUMN) is wrong.
PM>
I don’t know which object and which column he’s referring to.
Thank you!
Can you please edit your question by placing the contents of the last executed Migration? Edit using text. Avoid images.
– Leonel Sanches da Silva
All right, Gypsy.
– Raphael