I am new in MVC Entity Framework.
I have one Table called Product. it contain 40 fields.
I have one task to copy the Product or to create the duplicate record in same table with new Product ID..
How can I do this in efficient ways?
I tried using the below code
Public ActionResult CopyProduct(long ProductID)
{
var oldProductScript = db.Products.FirstOrDefault(x=>x.ProductID == ProductID)
Product p = new Product();
p.name = oldProductScript.name;
p.price =oldProductScript.price;
p.model =oldProductScript.model;
p.image = oldProductScript.image;
p.status =oldProductScript.status;
.
.
.
.
.
like so till 40th field
db.Products.AddObject(p);
db.SaveChanges();
}
Is this the proper way to complete this task?
Please suggest.
Thanks