This is my table
CREATE TABLE [dbo].[ProductsHondaofConyers](
[TagID] [int] NOT NULL,
[Sno] [nvarchar](max) NULL,
[Name] [nvarchar](max) NULL,
[Description] [nvarchar](max) NULL,
[Price] [nvarchar](max) NULL,
[Image] [nvarchar](max) NULL,
CONSTRAINT [PrimaryKey_d545e66e-4adb-4a3c-82dd-97220799da044] PRIMARY KEY CLUSTERED
(
[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 inserting data into database i want to entered value(TagId) already existing into database it show error message not exist store that data in to databasehow in MVC?
Controller:
[HttpPost]
public ActionResult Create(ProductsHondaofConyer p)
{
ProducdataDataContext db = new ProducdataDataContext();
db.ProductsHondaofConyers.InsertOnSubmit(p);
db.SubmitChanges();
return RedirectToAction("Index");
}
this is my controller code