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()



Fri May 15 2009 03:04:00 GMT-0700 (Pacific Daylight Time)



Disqus goes here