Skip to content
This repository was archived by the owner on Jul 10, 2024. It is now read-only.

Commit 4dbb912

Browse files
davidfowlDamianEdwards
authored andcommitted
Add EF error and work around
1 parent fc594e5 commit 4dbb912

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

docs/2. Build out BackEnd and Refactor.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,4 +406,64 @@ Okay, now we need to update our `ApplicationDbContext` so Entity Framework knows
406406
1. Run the application to see the updated data via Swagger UI.
407407
1. Use the Swagger UI to upload [NDC_Oslo_2019.json](/src/BackEnd/Data/Import/NDC_Oslo_2019.json) to the `/api/Sessions/upload` API.
408408

409+
## :warning: Using EF Core preview6 preview bits!
410+
There's a known issue where Entity Framework Core preview6 cannot properly handle the resuling model we have just built. Trying to run will result in an error looking something like this:
411+
412+
```
413+
System.InvalidOperationException: Operation is not valid due to the current state of the object.
414+
at Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.SqlExpressions.SubSelectExpression.Verify(SelectExpression selectExpression)
415+
at Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.SqlExpressions.SubSelectExpression..ctor(SelectExpression subquery)
416+
at Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalSqlTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
417+
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
418+
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
419+
at Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalSqlTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
420+
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
421+
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
422+
at Microsoft.EntityFrameworkCore.Query.NavigationExpansion.IncludeExpression.VisitChildren(ExpressionVisitor visitor)
423+
at System.Linq.Expressions.ExpressionVisitor.VisitExtension(Expression node)
424+
at Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalSqlTranslatingExpressionVisitor.VisitExtension(Expression extensionExpression)
425+
at System.Linq.Expressions.Expression.Accept(ExpressionVisitor visitor)
426+
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
427+
at Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalSqlTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
428+
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
429+
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
430+
at Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalSqlTranslatingExpressionVisitor.Translate(Expression expression)
431+
at Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalProjectionBindingExpressionVisitor.Visit(Expression expression)
432+
at Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalProjectionBindingExpressionVisitor.Translate(SelectExpression selectExpression, Expression expression)
433+
at Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.RelationalQueryableMethodTranslatingExpressionVisitor.TranslateSelect(ShapedQueryExpression source, LambdaExpression selector)
434+
at Microsoft.EntityFrameworkCore.Query.Pipeline.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
435+
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
436+
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
437+
at Microsoft.EntityFrameworkCore.Query.Pipeline.QueryCompilationContext2.CreateQueryExecutor[TResult](Expression query)
438+
at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery2[TResult](Expression query, Boolean async)
439+
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
440+
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass12_0`1.<ExecuteAsync>b__0()
441+
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
442+
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
443+
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync[TResult](Expression query, CancellationToken cancellationToken)
444+
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken)
445+
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1.System.Collections.Generic.IAsyncEnumerable<TResult>.GetEnumerator()
446+
at System.Linq.AsyncEnumerable.Aggregate_[TSource,TAccumulate,TResult](IAsyncEnumerable`1 source, TAccumulate seed, Func`3 accumulator, Func`2 resultSelector, CancellationToken cancellationToken) in D:\a\1\s\Ix.NET\Source\System.Interactive.Async\Aggregate.cs:line 118
447+
at BackEnd.Controllers.SessionsController.Get() in C:\Users\david\source\repos\ConferencePlannerv3\BackEnd\Controllers\SessionsController.cs:line 27
448+
at lambda_method(Closure , Object )
449+
at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()
450+
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
451+
at System.Threading.Tasks.ValueTask`1.get_Result()
452+
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
453+
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
454+
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
455+
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
456+
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
457+
--- End of stack trace from previous location where exception was thrown ---
458+
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
459+
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
460+
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
461+
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
462+
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
463+
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
464+
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
465+
```
466+
467+
To work around this, downgrade `Microsoft.EntityFrameworkCore.SqlServer`, `Microsoft.EntityFrameworkCore.Sqlite` and `Microsoft.EntityFrameworkCore.Tools` to version `2.2.4`.
468+
409469
**Next**: [Session #3 - Front-end](3.%20Add%20front-end%2C%20render%20agenda%2C%20set%20up%20front-end%20models.md) | **Previous**: [Session #1 - Setup, basic EF model](/docs/1.%20Create%20BackEnd%20API%20project.md)

0 commit comments

Comments
 (0)