ASP.NET MVC 4,从“创建”表单中删除主键

时间:2021-08-17 15:36:39

I am making my first mvc 4 project, database first, when I am using Scaffold to create Views and Control,

当我使用Scaffold创建视图和控件时,我正在制作我的第一个mvc 4项目,数据库优先,

its also adding Primary Key Field in Create and Edit page.

它还在“创建和编辑”页面中添加主键字段。

also on index page in place of Item.ProductId its showing /* id=item.PrimaryKey */

也在索引页面上代替Item.ProductId显示/ * id = item.PrimaryKey * /

what am I doing wrong. please help

我究竟做错了什么。请帮忙

Regards

问候

1 个解决方案

#1


1  

Are you referring to the placeholders? the /* id=item.PrimaryKey */, is just highlighting that you need to add your items primary key in place of this placeholder. Also, in the edit page, when you edit your item, you need to primary key to know which record to update.

你指的是占位符吗? / * id = item.PrimaryKey * /,只是突出显示您需要添加项目主键来代替此占位符。此外,在编辑页面中,当您编辑项目时,您需要使用主键来了解要更新的记录。

For example, if you had a table of Products, and your primary key was ProductId, then you would replace the commented out line with id=item.ProductId.

例如,如果您有一个Products表,而您的主键是ProductId,那么您将用id = item.ProductId替换注释掉的行。

#1


1  

Are you referring to the placeholders? the /* id=item.PrimaryKey */, is just highlighting that you need to add your items primary key in place of this placeholder. Also, in the edit page, when you edit your item, you need to primary key to know which record to update.

你指的是占位符吗? / * id = item.PrimaryKey * /,只是突出显示您需要添加项目主键来代替此占位符。此外,在编辑页面中,当您编辑项目时,您需要使用主键来了解要更新的记录。

For example, if you had a table of Products, and your primary key was ProductId, then you would replace the commented out line with id=item.ProductId.

例如,如果您有一个Products表,而您的主键是ProductId,那么您将用id = item.ProductId替换注释掉的行。