Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqlException: Incorrect syntax near the keyword 'WITH' #556

Open
yasirkhanmkd opened this issue Mar 4, 2025 · 2 comments
Open

SqlException: Incorrect syntax near the keyword 'WITH' #556

yasirkhanmkd opened this issue Mar 4, 2025 · 2 comments

Comments

@yasirkhanmkd
Copy link

When ever I try to create a Page then the below exception occurs.
Stack is as given

SqlException: Incorrect syntax near the keyword 'WITH'. Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.

Microsoft.Data.SqlClient.SqlCommand+<>c.b__211_0(Task result)
System.Threading.Tasks.ContinuationResultTaskFromResultTask<TAntecedentResult, TResult>.InnerInvoke()
System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, object state)
System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, object state)
System.Threading.Tasks.Task.ExecuteWithThreadLocal(ref Task currentTaskSlot, Thread threadPoolThread)
Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable+AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync<TState, TResult>(TState state, Func<DbContext, TState, CancellationToken, Task> operation, Func<DbContext, TState, CancellationToken, Task<ExecutionResult>> verifySucceeded, CancellationToken cancellationToken)
Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable+AsyncEnumerator.MoveNextAsync()
System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable+ConfiguredValueTaskAwaiter.GetResult()
Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync(IQueryable source, CancellationToken cancellationToken)
Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync(IQueryable source, CancellationToken cancellationToken)
Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToArrayAsync(IQueryable source, CancellationToken cancellationToken)
Cofoundry.Domain.Internal.GetPageRoutingInfoByCustomEntityIdRangeQueryHandler.GetIdSetsAsync(GetPageRoutingInfoByCustomEntityIdRangeQuery query) in GetPageRoutingInfoByCustomEntityIdRangeQueryHandler.cs
+
var dbResult = await _dbContext
Cofoundry.Domain.Internal.GetPageRoutingInfoByCustomEntityIdRangeQueryHandler.ExecuteAsync(GetPageRoutingInfoByCustomEntityIdRangeQuery query, IExecutionContext executionContext) in GetPageRoutingInfoByCustomEntityIdRangeQueryHandler.cs
+
var idSets = await GetIdSetsAsync(query);
Cofoundry.Domain.CQS.Internal.QueryExecutor.ExecuteQueryAsync<TQuery, TResult>(TQuery query, IExecutionContext executionContext) in QueryExecutor.cs
+
var result = await handler.ExecuteAsync(query, cx);
Cofoundry.Domain.CQS.Internal.QueryExecutor.ExecuteAsync(IQuery query, IExecutionContext executionContext) in QueryExecutor.cs
+
result = await task;
Cofoundry.Domain.Internal.CustomEntitySummaryMapper.MapAsync(IReadOnlyCollection dbStatusQueries, IExecutionContext executionContext) in CustomEntitySummaryMapper.cs
+
var routings = await _queryExecutor.ExecuteAsync(routingsQuery, executionContext);
Cofoundry.Domain.Internal.SearchCustomEntitySummariesQueryHandler.ExecuteAsync(SearchCustomEntitySummariesQuery query, IExecutionContext executionContext) in SearchCustomEntitySummariesQueryHandler.cs
+
var mappedResult = await _customEntitySummaryMapper.MapAsync(dbPagedResult.Items, executionContext);
Cofoundry.Domain.CQS.Internal.QueryExecutor.ExecuteQueryAsync<TQuery, TResult>(TQuery query, IExecutionContext executionContext) in QueryExecutor.cs
+
var result = await handler.ExecuteAsync(query, cx);
Cofoundry.Domain.CQS.Internal.QueryExecutor.ExecuteAsync(IQuery query, IExecutionContext executionContext) in QueryExecutor.cs
+
result = await task;
Cofoundry.Web.Internal.ApiResponseHelper.RunWithResultAsync(Func<Task> functionToExecute) in ApiResponseHelper.cs
+
var result = await functionToExecute();
Cofoundry.Web.Admin.CustomEntityDefinitionsApiController.GetCustomEntities(string customEntityDefinitionCode, SearchCustomEntitySummariesQuery query) in CustomEntityDefinitionsApiController.cs
+
return await _apiResponseHelper.RunQueryAsync(query);
lambda_method1313(Closure , object )
Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor+TaskOfActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, object controller, object[] arguments)
System.Threading.Tasks.ValueTask.get_Result()
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Logged|12_1(ControllerActionInvoker invoker)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)
Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|7_0(Endpoint endpoint, Task requestTask, ILogger logger)
Cofoundry.Web.AutoUpdateMiddleware.Invoke(HttpContext cx) in AutoUpdateMiddleware.cs
+
await _next.Invoke(cx);
Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

@HeyJoel
Copy link
Member

HeyJoel commented Mar 6, 2025

Which version of Cofoundry and SQLServer are you using?

@HeyJoel
Copy link
Member

HeyJoel commented Mar 6, 2025

It looks like it could be an EF8 issue with older databases or SQL compatibility levels if you're using version prior to 2016. Requirements for the latest verison of Cofoundry are 2016 or later. Having said that, SQL 2016 is out of support and 2019 will soon be out of mainstream support so I expect we'll be upgrading the requirements in the next release to 2022 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants