Note that there are some explanatory texts on larger screens.

plurals
  1. POEF code first Invalid column name
    primarykey
    data
    text
    <p>I'm currently working on my own simple CMS using MVC to familiarize myself with MVC and EF. </p> <p>At this time I've only got pages which can contain multiple paragraphs. In the database I've got 1 page (Home) and 1 paragraph. </p> <p>On the index view of home I'm calling the GetParagraph action of my controller to get the paragraph based on the placeholder value. The placeholder value is being send correctly to the controller and the query. But I'm getting an exception when the query tries to access the database to retrieve the record.</p> <p><strong>Exception</strong></p> <pre><code>{"Invalid column name 'ParagraphId'.\r\nInvalid column name 'PageId'.\r\nInvalid column name 'LinkUrl'.\r\nInvalid column name 'LinkText'.\r\nInvalid column name 'LinkTarget'.\r\nInvalid column name 'ImageUrl'.\r\nInvalid column name 'ImageLink'.\r\nInvalid column name 'ImageLinkTarget'.\r\nInvalid column name 'ImageAlt'."} </code></pre> <p><strong>Models</strong></p> <pre><code> public class Page { [Key] public int PageId { get; set; } [DisplayName("Parent")] public int? ParentId { get; set; } [Required] public string Title { get; set; } [Required] [DisplayName("View name")] public string ViewName { get; set; } [DataType(DataType.Date)] public DateTime Created = DateTime.Now; [Required] public bool Published { get; set; } public virtual ICollection&lt;Paragraph&gt; Paragraphs { get; set; } } public class Paragraph { [Key] public int ParagraphId { get; set; } public int PageId { get; set; } public virtual Page Page { get; set; } public string Placeholder { get; set; } public string Title { get; set; } [AllowHtml] [DataType(DataType.MultilineText)] public string Text { get; set; } public string LinkUrl { get; set; } public string LinkText { get; set; } public string LinkTarget { get; set; } public string ImageUrl { get; set; } public string ImageLink { get; set; } public string ImageLinkTarget { get; set; } public string ImageAlt { get; set; } [DataType(DataType.Date)] public DateTime Created = DateTime.Now; [Required] public bool Published { get; set; } } </code></pre> <p><strong>Controller</strong></p> <pre><code>public class PzzlController : Controller { PzzlDB _db = new PzzlDB(); public ActionResult GetParagraph(string placeholder) { var viewModel = _db.Paragraphs.GetParagraphByPlaceholder(placeholder); if (viewModel != null) { return PartialView("~/Views/Shared/Pzzl/_Paragraph.cshtml", viewModel); } else { return null; } } } </code></pre> <p><strong>Query</strong></p> <pre><code>public static Paragraph GetParagraphByPlaceholder( this IQueryable&lt;Paragraph&gt; Paragraph, string placeholder) { try { return Paragraph.Single(p =&gt; p.Placeholder == placeholder); } catch (Exception) { return null; } } </code></pre> <p><strong>Contents of Paragraph variable</strong></p> <pre><code>Local = 'System.Linq.IQueryable&lt;Pzzl.Models.Pzzl.Paragraph&gt;' does not contain a definition for 'Local' and no extension method 'Local' accepting a first argument of type 'System.Linq.IQueryable&lt;Pzzl.Models.Pzzl.Paragraph&gt;' could be found (are you missing a using di... </code></pre> <p><strong>Stacktrace</strong></p> <pre><code>[SqlException (0x80131904): Invalid column name 'ParagraphId'. Invalid column name 'PageId'. Invalid column name 'LinkUrl'. Invalid column name 'LinkText'. Invalid column name 'LinkTarget'. Invalid column name 'ImageUrl'. Invalid column name 'ImageLink'. Invalid column name 'ImageLinkTarget'. Invalid column name 'ImageAlt'.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +1753986 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5296058 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +558 System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean&amp; dataReady) +1682 System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() +59 System.Data.SqlClient.SqlDataReader.get_MetaData() +90 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +365 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task&amp; task, Boolean asyncWrite) +1379 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task&amp; task, Boolean asyncWrite) +175 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +53 System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +134 System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +41 System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) +10 System.Data.Entity.Infrastructure.Interception.&lt;&gt;c__DisplayClassb.&lt;Reader&gt;b__8() +69 System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch(Func`1 operation, TInterceptionContext interceptionContext, Action`1 executing, Action`1 executed) +93 System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext) +320 System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior) +240 System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) +10 System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior) +104 [EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details.] System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior) +188 System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute(ObjectContext context, ObjectParameterCollection parameterValues) +1283 System.Data.Entity.Core.Objects.&lt;&gt;c__DisplayClass3.&lt;GetResults&gt;b__2() +185 System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction(Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess) +499 System.Data.Entity.Core.Objects.&lt;&gt;c__DisplayClass3.&lt;GetResults&gt;b__1() +271 System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func`1 operation) +251 System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) +600 System.Data.Entity.Core.Objects.ObjectQuery`1.&lt;System.Collections.Generic.IEnumerable&lt;T&gt;.GetEnumerator&gt;b__0() +89 System.Lazy`1.CreateValue() +416 System.Lazy`1.LazyInitValue() +152 System.Lazy`1.get_Value() +75 System.Data.Entity.Internal.LazyEnumerator`1.MoveNext() +40 System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source) +4078797 System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.&lt;GetElementFunction&gt;b__2(IEnumerable`1 sequence) +83 System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.ExecuteSingle(IEnumerable`1 query, Expression queryRoot) +107 System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute(Expression expression) +197 System.Data.Entity.Internal.Linq.DbQueryProvider.Execute(Expression expression) +149 System.Linq.Queryable.SingleOrDefault(IQueryable`1 source, Expression`1 predicate) +287 Pzzl.Queries.Pzzl.ParagraphQueries.GetParagraphByPlaceholder(IQueryable`1 Paragraph, String placeholder) in C:\Projects\Speeltuin\MVCWebsite\Portfolio\Pzzl\Queries\Pzzl\ParagraphQueries.cs:43 Portfolio.Controllers.PzzlController.GetParagraphTitle(String placeholder) in C:\Projects\Speeltuin\MVCWebsite\Portfolio\Portfolio\Controllers\PzzlController.cs:17 lambda_method(Closure , ControllerBase , Object[] ) +180 System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +214 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27 Castle.Proxies.ControllerActionInvokerProxy.InvokeActionMethod_callback(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +47 Castle.Proxies.Invocations.ControllerActionInvoker_InvokeActionMethod.InvokeMethodOnTarget() +226 Castle.DynamicProxy.AbstractInvocation.Proceed() +117 Glimpse.Core.Extensibility.CastleInvocationToAlternateMethodContextAdapter.Proceed() +48 Glimpse.Core.Extensibility.ExecutionTimer.Time(Action action) +195 Glimpse.Core.Extensions.AlternateMethodContextExtensions.TryProceedWithTimer(IAlternateMethodContext context, TimerResult&amp; timerResult) +198 Glimpse.Core.Extensibility.AlternateMethod.NewImplementation(IAlternateMethodContext context) +45 Glimpse.Core.Extensibility.AlternateTypeToCastleInterceptorAdapter.Intercept(IInvocation invocation) +183 Castle.DynamicProxy.AbstractInvocation.Proceed() +483 Castle.Proxies.ControllerActionInvokerProxy.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +235 System.Web.Mvc.&lt;&gt;c__DisplayClass15.&lt;InvokeActionMethodWithFilters&gt;b__12() +55 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +253 System.Web.Mvc.&lt;&gt;c__DisplayClass17.&lt;InvokeActionMethodWithFilters&gt;b__14() +21 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +324 System.Web.Mvc.Controller.ExecuteCore() +106 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +91 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10 System.Web.Mvc.&lt;&gt;c__DisplayClassb.&lt;BeginProcessRequest&gt;b__5() +34 System.Web.Mvc.Async.&lt;&gt;c__DisplayClass1.&lt;MakeVoidDelegate&gt;b__0() +19 System.Web.Mvc.Async.&lt;&gt;c__DisplayClass8`1.&lt;BeginSynchronous&gt;b__7(IAsyncResult _) +10 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62 System.Web.Mvc.&lt;&gt;c__DisplayClasse.&lt;EndProcessRequest&gt;b__d() +48 System.Web.Mvc.SecurityUtil.&lt;GetCallInAppTrustThunk&gt;b__0(Action f) +7 System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9 System.Web.Mvc.&lt;&gt;c__DisplayClassa.&lt;EndProcessRequest&gt;b__9() +22 System.Web.Mvc.&lt;&gt;c__DisplayClass4.&lt;Wrap&gt;b__3() +10 System.Web.Mvc.ServerExecuteHttpHandlerWrapper.Wrap(Func`1 func) +27 System.Web.Mvc.ServerExecuteHttpHandlerWrapper.Wrap(Action action) +65 System.Web.Mvc.ServerExecuteHttpHandlerAsyncWrapper.EndProcessRequest(IAsyncResult result) +71 System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride) +1097 [HttpException (0x80004005): Fout bij uitvoeren van onderliggende aanvraagelement voor handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'.] System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride) +3122411 System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage) +76 System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) +28 System.Web.HttpServerUtilityWrapper.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) +19 System.Web.Mvc.Html.ChildActionExtensions.ActionHelper(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues, TextWriter textWriter) +483 System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper htmlHelper, String actionName, String controllerName, Object routeValues) +58 ASP._Page_Views_Home_Index_cshtml.Execute() in c:\Projects\Speeltuin\MVCWebsite\Portfolio\Portfolio\Views\Home\Index.cshtml:10 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +197 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +81 System.Web.WebPages.StartPage.RunPage() +17 System.Web.WebPages.StartPage.ExecutePageHierarchy() +62 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +76 System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +222 System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115 Castle.Proxies.Invocations.IView_Render.InvokeMethodOnTarget() +188 Castle.DynamicProxy.AbstractInvocation.Proceed() +117 Glimpse.Core.Extensibility.CastleInvocationToAlternateMethodContextAdapter.Proceed() +48 Glimpse.Core.Extensibility.ExecutionTimer.Time(Action action) +195 Glimpse.Core.Extensions.AlternateMethodContextExtensions.TryProceedWithTimer(IAlternateMethodContext context, TimerResult&amp; timerResult) +198 Glimpse.Core.Extensibility.AlternateMethod.NewImplementation(IAlternateMethodContext context) +45 Glimpse.Core.Extensibility.AlternateTypeToCastleInterceptorAdapter.Intercept(IInvocation invocation) +183 Castle.DynamicProxy.AbstractInvocation.Proceed() +483 Castle.Proxies.IViewProxy.Render(ViewContext viewContext, TextWriter writer) +202 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +295 System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13 Castle.Proxies.ControllerActionInvokerProxy.InvokeActionResult_callback(ControllerContext controllerContext, ActionResult actionResult) +39 Castle.Proxies.Invocations.ControllerActionInvoker_InvokeActionResult.InvokeMethodOnTarget() +182 Castle.DynamicProxy.AbstractInvocation.Proceed() +117 Glimpse.Core.Extensibility.CastleInvocationToAlternateMethodContextAdapter.Proceed() +48 Glimpse.Core.Extensibility.ExecutionTimer.Time(Action action) +195 Glimpse.Core.Extensions.AlternateMethodContextExtensions.TryProceedWithTimer(IAlternateMethodContext context, TimerResult&amp; timerResult) +198 Glimpse.Core.Extensibility.AlternateMethod.NewImplementation(IAlternateMethodContext context) +45 Glimpse.Core.Extensibility.AlternateTypeToCastleInterceptorAdapter.Intercept(IInvocation invocation) +183 Castle.DynamicProxy.AbstractInvocation.Proceed() +483 Castle.Proxies.ControllerActionInvokerProxy.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +219 System.Web.Mvc.&lt;&gt;c__DisplayClass1c.&lt;InvokeActionResultWithFilters&gt;b__19() +23 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +242 System.Web.Mvc.&lt;&gt;c__DisplayClass1e.&lt;InvokeActionResultWithFilters&gt;b__1b() +21 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +324 System.Web.Mvc.Controller.ExecuteCore() +106 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +91 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10 System.Web.Mvc.&lt;&gt;c__DisplayClassb.&lt;BeginProcessRequest&gt;b__5() +34 System.Web.Mvc.Async.&lt;&gt;c__DisplayClass1.&lt;MakeVoidDelegate&gt;b__0() +19 System.Web.Mvc.Async.&lt;&gt;c__DisplayClass8`1.&lt;BeginSynchronous&gt;b__7(IAsyncResult _) +10 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62 System.Web.Mvc.&lt;&gt;c__DisplayClasse.&lt;EndProcessRequest&gt;b__d() +48 System.Web.Mvc.SecurityUtil.&lt;GetCallInAppTrustThunk&gt;b__0(Action f) +7 System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9628972 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +155 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload