System.Data.EntitySqlException
System.Data.EntitySqlException: ‘ExceptionRecord’ could not be resolved in the current scope or context.
This seemingly small Exception took a while to figure out. I was calling the ObjectContext constructor without specifying the default container name. Adding that solved the problem and now the Entity Framework is happily talking to SQL Server Compact again.
For anyone else looking for a solution to this, here’s the stack trace you might see:
System.Data.EntitySqlException: ‘ExceptionRecord’ could not be resolved in the current scope or context. Make sure that all referenced variables are in scope, that required schemas are loaded, and that namespaces are referenced correctly., near escaped identifier.
at System.Data.Common.EntitySql.CqlErrorHelper.ReportIdentifierError(Expr expr, SemanticResolver sr)
at System.Data.Common.EntitySql.SemanticAnalyzer.ConvertIdentifier(Expr expr, SemanticResolver sr)
at System.Data.Common.EntitySql.SemanticAnalyzer.Convert(Expr astExpr, SemanticResolver sr)
at System.Data.Common.EntitySql.SemanticAnalyzer.ConvertRootExpression(Expr astExpr, SemanticResolver sr)
at System.Data.Common.EntitySql.SemanticAnalyzer.Analyze(Expr astExpr, DbCommandTree commandTree)
at System.Data.Common.EntitySql.CqlQuery.AnalyzeSemantics(DbCommandTree builderTree, Expr astExpr, Perspective perspective, ParserOptions parserOptions, Dictionary`2 parameters, Dictionary`2 variables)
at System.Data.Common.EntitySql.CqlQuery.Compile(DbCommandTree builderTree, String queryText, Perspective perspective, ParserOptions parserOptions, Dictionary`2 parameters, Dictionary`2 variables)
at System.Data.Objects.EntitySqlQueryState.Parse(DbCommandTree parseTree)
at System.Data.Objects.EntitySqlQueryState.GetExecutionPlan(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable.GetEnumerator()
about 1 year ago
I am having the problem described in this article. Everything works great except when I first sort by one column and then try to group by a second. That is when I get the following error.
“System.Data.EntitySqlException: ‘ValueNum’ could not be resolved in the current scope or context. Make sure that all referenced variables are in scope, that required schemas are loaded, and that namespaces are referenced correctly., near simple identifier, line 6, column 1.”
I ran across your article when trying to research this problem, so I thought I’d ask. What do I need to do to fix this? I am running an Infragistics UltraWebGrid with an EntityDataSource. All grouping, paging, sorting, etc. is enabled along with auto-insert/update/delete. Thanks!