Open Closed

Executing Background Jobs ef SQL error #6179


User avatar
0
  • ABP Framework version: v7.4.1
  • UI Type: MVC
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
[2023-11-15 12:42:02.262] [Error] DEV1-PC () <Microsoft.EntityFrameworkCore.Database.Command> Failed executing DbCommand ("3"ms) [Parameters=["@__p_1='?' (DbType = Int32), @__now_0='?' (DbType = DateTime2)"], CommandType='Text', CommandTimeout='30']"\r\n""SELECT TOP(@__p_1) [a].[Id], [a].[ConcurrencyStamp], [a].[CreationTime], [a].[ExtraProperties], [a].[IsAbandoned], [a].[JobArgs], [a].[JobName], [a].[LastTryTime], [a].[NextTryTime], [a].[Priority], [a].[TryCount]\r\nFROM [AbpBackgroundJobs] AS [a]\r\nWHERE [a].[IsAbandoned] = CAST(0 AS bit) AND [a].[NextTryTime] <= @__now_0\r\nORDER BY [a].[Priority] DESC, [a].[TryCount], [a].[NextTryTime]"
[2023-11-15 12:42:02.263] [Error] DEV1-PC () <Microsoft.EntityFrameworkCore.Query> An exception occurred while iterating over the results of a query for context type '"Volo.Abp.BackgroundJobs.EntityFrameworkCore.BackgroundJobsDbContext"'."\r\n""Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid column name 'ConcurrencyStamp'.\r\nInvalid column name 'ExtraProperties'.\r\nInvalid column name 'JobName'.\r\n   at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__209_0(Task`1 result)\r\n   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()\r\n   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n--- End of stack trace from previous location ---\r\n   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)\r\n--- End of stack trace from previous location ---\r\n   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)\r\n   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)\r\n   at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()\r\nClientConnectionId:1067e9e4-b969-4ddb-a740-d5b5df69f130\r\nError Number:207,State:1,Class:16"
Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid column name 'ConcurrencyStamp'.
Invalid column name 'ExtraProperties'.
Invalid column name 'JobName'.
   at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__209_0(Task`1 result)
   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()

From what I can tell, the columns it's complaining about do exist and there are no pending migrations.

This is what's in the model snapshot as well, which also seems correct:

modelBuilder.Entity("Volo.Abp.BackgroundJobs.BackgroundJobRecord", b =>
    {
        b.Property<Guid>("Id")
            .ValueGeneratedOnAdd()
            .HasColumnType("uniqueidentifier");

        b.Property<string>("ConcurrencyStamp")
            .IsConcurrencyToken()
            .IsRequired()
            .HasMaxLength(40)
            .HasColumnType("nvarchar(40)")
            .HasColumnName("ConcurrencyStamp");

        b.Property<DateTime>("CreationTime")
            .HasColumnType("datetime2")
            .HasColumnName("CreationTime");

        b.Property<string>("ExtraProperties")
            .IsRequired()
            .HasColumnType("nvarchar(max)")
            .HasColumnName("ExtraProperties");

        b.Property<bool>("IsAbandoned")
            .ValueGeneratedOnAdd()
            .HasColumnType("bit")
            .HasDefaultValue(false);

        b.Property<string>("JobArgs")
            .IsRequired()
            .HasMaxLength(1048576)
            .HasColumnType("nvarchar(max)");

        b.Property<string>("JobName")
            .IsRequired()
            .HasMaxLength(128)
            .HasColumnType("nvarchar(128)");

        b.Property<DateTime?>("LastTryTime")
            .HasColumnType("datetime2");

        b.Property<DateTime>("NextTryTime")
            .HasColumnType("datetime2");

        b.Property<byte>("Priority")
            .ValueGeneratedOnAdd()
            .HasColumnType("tinyint")
            .HasDefaultValue((byte)15);

        b.Property<short>("TryCount")
            .ValueGeneratedOnAdd()
            .HasColumnType("smallint")
            .HasDefaultValue((short)0);

        b.HasKey("Id");

        b.HasIndex("IsAbandoned", "NextTryTime");

        b.ToTable("AbpBackgroundJobs", (string)null);
    });

Any ideas?


2 Answer(s)
  • User Avatar
    0

    Just using standard localdb for local dev:

    "ConnectionStrings": {
      "Default": "Server=(localdb)\\MSSQLLocalDB;Database=ProjectDb;Trusted_Connection=True;TrustServerCertificate=True"
    }
    

    Also, if it were a general permissions issue - I would have expected far more to be wrong, but everything works except this for me.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    1. Ensure the ConnectionStrings are the same in all projects.
    2. You can remove all existing migrations and re-create one, then migrate to a new database for troubleshooting.
Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09