I'm creating a non-trivial but relatively simple ASP.NET MVC v1.0 applet ~~
it's very much similar to the movie database example of tutorial number one.
It was working, more or less, until I added the Edit code. It dies in code like
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edit(Movie movieToEdit)
on
_db.ApplyPropertyChanges(originalMovie.EntityKey.EntitySetName, movieToEdit);
The reason it's dying is because it's unhappy with the SQL timestamp field I've added:
changeControl timestamp
The fix should be simple, although I'm momentarily unsure of the syntax: I'm guessing I need to
add something like [Bind(Exclude = "changeControl")] to:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edit(Movie movieToEdit, [Bind(Exclude = "changeControl")])
Please note: it seems to me that since timestamp fields are immutable from the
developer's perspective (AFAIK, only SQL Server can change them),
this looks like a MVC bug to me. ?? bug # 1 ??
MORE INFORMATION (problem description)
Here's the problem that I'm having:
I noticed that I had spelled "changeControl" incorrectly as "chnageControl".
In the .mdf, via the Server Explorer, I correct "chnageControl" to "changeControl".
Problem: every time I try to run my MVC solution, it dies at
public ActionResult Index() // Article Controller "Index"
{
return View(_db.NewsArticleSet.ToList()); // dies here
}
with {"Invalid column name 'chnageControl'."}
I have used VS2008 Pro SP1 Find to hunt for chnageControl throughout my entire
solution and it can not find it. I've examined the .mdf in Server Explorer
and see no trace of chnageControl. I even copied the .mdf to another computer and
attached it to SQL Server 2008 Express to examine it in a different environment.
Again, I can find no trace of chnageControl. I've even rebooted my development computer,
again, without success.
How do I make VS2008 forget about the chnageControl artifact? ?? bug # 2 ??
Thank you.
Regards,
Gerry (Lowry)
System.Data.EntityCommandExecutionException was unhandled by user code
Message="An error occurred while executing the command definition. See the inner exception for details."
Source="System.Data.Entity"
StackTrace:
at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behaviour)
at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at mne.Controllers.ArticleController.Index() in C:\!!!!!mne\mne\mne\Controllers\ArticleController.cs:line 34
at lambda_method(ExecutionScope , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassa.<InvokeActionMethodWithFilters>b__7()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
InnerException: System.Data.SqlClient.SqlException
Message="Invalid column name 'chnageControl'." ?? bug # 2 ??
Source=".Net SqlClient Data Provider"
ErrorCode=-2146232060
Class=16
LineNumber=21
Number=207
Procedure=""
Server="\\\\.\\pipe\\49364F80-F3FA-40\\tsql\\query"
State=1
StackTrace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
InnerException:
Gerry Lowry, Principal
Ability Business Computer Services ~~ Because it's your Business, our Experience Counts!
68 John W. Taylor Avenue
Alliston · Ontario · Canada · L9R 0E1 · gerry.lowry@abilitybusinesscomputerservices.com
Websites:
http://abilitybusinesscomputerservices.comhttp://gerrylowryprogrammer.com ~~
résumé & testimonials
http://veganoccasions.com ~~ recipes by
Susan