我有一个表在我的数据库是这样的:插入新记录到数据库中使用实体框架
[id] [uniqueidentifier] NOT NULL,
[user_id] [uniqueidentifier] NOT NULL,
[download_type] [nvarchar](50) NOT NULL,
[download_id] [nvarchar](50) NOT NULL,
[download_date] [datetime] NOT NULL,
[user_ip_address] [nvarchar](20) NOT NULL,
的id
被定义主键。
我想插入一个新的记录到这张表中。这是我无法上班的代码。
CustomerPortalEntities_Customer_Downloads dbcd = new CustomerPortalEntities_Customer_Downloads();
public ActionResult Download(string id)
{
var collection = new FormCollection();
collection.Add("user_id", Membership.GetUser().ProviderUserKey.ToString());
collection.Add("download_type", "Car");
collection.Add("download_id", id);
collection.Add("download_date", DateTime.Now.ToString());
collection.Add("user_ip_address", Request.ServerVariables["REMOTE_ADDR"]);
dbcd.AddToCustomer_Downloads(collection);
return Redirect("../../Content/files/" + id + ".EXE");
}
我得到的错误是在线dbcd.AddToCustomer_Downloads(collection);
的最好重载方法匹配 'CustomerPortalMVC.Models.CustomerPortalEntities_Customer_Downloads.AddToCustomer_Downloads(CustomerPortalMVC.Models.Customer_Downloads)' 有一些无效参数
参数 '1':不能从“的System.Web转换。 Mvc.FormCollection”到 ‘CustomerPortalMVC.Models.Customer_Downloads’
什么我需要改变,以使这项工作?
男人,我知道这是愚蠢的东西简单,由于是工作! –