Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have just started on a new project, where the database is built using code first.

I have attempted to run the project for the first time and get the below Exception. I have checked that

using (var serviceScope = serviceProvider.CreateScope())
{
    var db = serviceScope.ServiceProvider.GetService<ILoggingDbContext>();
    await db.Database.MigrateAsync();

}



1. No database changes have been made to the Dev Database.
2. Check that other Dev's on the team don't have the same problem.

I have tried to google the exception message, but each result talks about the database changes that I am trying to make.

Can anyone give me a pointer on things to do next?

System.Data.SqlClient.SqlException
  HResult=0x80131904
  Message=Either the parameter @objname is ambiguous or the claimed @objtype (COLUMN) is wrong.
  Source=Core .Net SqlClient Data Provider
  StackTrace:
   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.EndExecuteNonQueryInternal(IAsyncResult asyncResult)
   at System.Data.SqlClient.SqlCommand.EndExecuteNonQuery(IAsyncResult asyncResult)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.<ExecuteAsync>d__17.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Microsoft.EntityFrameworkCore.Migrations.MigrationCommand.<ExecuteNonQueryAsync>d__8.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.<ExecuteNonQueryAsync>d__1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.<MigrateAsync>d__12.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at FFO.Data.Helpers.Startup.LoggingEfStartup.<InitializeDatabaseAsync>d__0.MoveNext() in C:\Users\simon_whale\Source\Repos\fleet fine online\FleetFineOnline\FFO-Data\Helpers\Startup\LoggingEFStartup.cs:line 17


What I have tried:

A lot of Google Fo on the following Exception

SqlException: Either the parameter @objname is ambiguous or the claimed @objtype (COLUMN) is wrong.


Checking with other Developers
Reinstalling the Branch for the project.
Posted
Updated 26-Oct-18 3:17am
v3
Comments
Richard Deeming 26-Oct-18 9:28am    
You could try using Script-Migration[^] to generate a SQL migration script, in case there's anything obviously wrong with the script.
Simon_Whale 26-Oct-18 11:24am    
thanks Richard,

I am going to have to pick this up on monday as it appears that I don't yet have access to SQL Server and the boss has gone home. after trawling through the exception it fails when trying to run the sp_rename.

Then when i try to run the commands suggested in your link to also falls over for me which I believe is down to no access to the database.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900