The column "xxx" cannot be modified because it is either a computed column or is the result of a UNI

Posted by Mandlaa under ASP.NET MVC on 3/21/2014 | Points: 10 | Views : 3373 | Status : [Member] | Replies : 0
This is my table Structure,

CREATE TABLE [dbo].[Productsdata](
[ID] [int] IDENTITY(1,1) NOT NULL,
[TagId] AS ('100.1.'+CONVERT([varchar](10),[ID],(0))) PERSISTED NOT NULL,
[Name] [varchar](max) NULL,
[Address] [int] NULL,

CONSTRAINT [PrimaryKey_92b4ebad-47f3-4b86-8d04-720c8511b79e] PRIMARY KEY CLUSTERED
(
[ID] ASC,
[TagId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
)

GO
At the time of insert new record my table Using MVC4 with Linq I am getting an error like this:

ERROR:

The column "TagId" cannot be modified because it is either a computed column or is the result of a UNION operator.
This is my code for inserting new record

public ActionResult Createnewcar()
{
Productsdata p = new Productsdata();
return View(p);
}

// POST: /Products/Create
[HttpPost, ValidateInput(false)]
public ActionResult Createnewcar(FormCollection collection, Productsdata p, HttpPostedFileBase[] MultipleFiles)
{
try
{
var Tagid = collection["TagNo"];
var qry = (from c in db.Productsdatas where c.TagId ==Tagid select c).Count();
if (qry != 1)
{
db.Productsdatas.InsertOnSubmit(p);
db.SubmitChanges();
return RedirectToAction("Index");
}
else
{
return RedirectToAction("EventCreationError");
}
}
catch
{
return RedirectToAction("Createnewcar");
}
}
What is the mistake my code?

Give me the solution for this one




Responses

(No response found.)

Login to post response