Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我运行员工详细信息视图时,会显示以下错误。没有与数据库连接相关的问题。
列表项定义此 EntityType 的键。雇员:EntityType:EntitySet 'Employees' 基于没有定义键的类型'Employee'。
如果属性被调用Id或<class name>Id.
Id
<class name>Id.
因此,只需将此类属性添加到您的模型中,或者您也可以使用[Key]属性将其映射为主键。
[Key]
例如:
public class Employee { [Key] public int EmployeeId { get; set; } //Other properties }