2015-01-06 5 views
0

작동하지 :키 주석 나는 다음과 같은 오류를 받고 있어요

Error 1 The type or namespace name 'keyAttribute' could not be found (are you missing a using directive or an assembly reference?)

enter code here

c:\users\hp\documents\visual studio 2013\Projects\ProductApps\ProductApps\Models\Product.cs 13 10 ProductApps

내 코드 :

using System; 
using System.Collections.Generic; 
using System.ComponentModel.DataAnnotations; 
using System.Linq; 
using System.Web; 


namespace ProductApps.Models 
{ 
    public class Product 
    { 
     [key] 
     public int Id { get; set; } 
     public string ProductName { get; set; } 
     public string Price { get; set; } 
     public string Description { get; set; } 
    } 
} 

인가 나는 오류가 발생하고 해결 방법을하는거야 이유를 제시 할 수 누구?

+0

기본 키를 사용하려고 했습니까 – Aravindan

답변

3

당신의 using 문에

using System.ComponentModel.DataAnnotations; 

를 추가하고 System.ComponentModel.Annotations.dll 어셈블리가 프로젝트에

[Key] 
public int Id { get; set; } 
+0

지시어를 사용하는 것은 이미 질문의 코드에 있습니다. – Richard

+0

감사합니다. #vgSefa. 주석 이름 '키'의 작은 글자였습니다. 왜 내가 오류가 발생하는지. 지금 그 일 : –

-1

을 참조한 마십시오 (자본 K와) 같은 시도하세요?

+0

나는 MVC의 초보자라고 언급해야한다. System.ComponentModel.Annotations.dll을 추가했는지 여부를 어떻게 알 수 있습니까? –

+0

@masudshrabon 프로젝트 탐색기에서 "참조"아래에서 찾을 수 있습니다. 표시되지 않으면 "참조"를 마우스 오른쪽 단추로 클릭하고 "참조 추가"를 선택하십시오. – Alexander

관련 문제