/// <summary>
 /// Create a new cg_Products object.
 /// </summary>
 /// <param name="productId">Initial value of the ProductId property.</param>
 public static cg_Products Createcg_Products(global::System.Int64 productId)
 {
     cg_Products cg_Products = new cg_Products();
     cg_Products.ProductId = productId;
     return cg_Products;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the cg_Products EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTocg_Products(cg_Products cg_Products)
 {
     base.AddObject("cg_Products", cg_Products);
 }
        public ActionResult product_new(FormCollection collection)
        {
            var newItem = new cg_Products();

            // add values
            newItem.Name = collection["productName"];
            newItem.ProductCode = collection["productCode"];
            newItem.cg_DestinationsReference.EntityKey = new System.Data.EntityKey("caval_goEntities.cg_Destinations", "DestinationId", long.Parse(collection["DestinationId"]));

            // add to DB & save
            db.AddTocg_Products(newItem);
            db.SaveChanges();

            return RedirectToAction("products");
        }