2011-05-11 2 views
1

EF4 및 CTP5와 함께 Web Forms (MVC 아님)에서 코드 우선을 사용하고 있으며 [Key] 속성을 사용하여 속성을 꾸리려고하면 나타나지 않습니다 Intellisense에서 KeyAttribute를 찾을 수 없다는 컴파일 오류가 발생합니다. 여기 내 코드는 다음과 같습니다.웹 양식 EF4 CodeFirst CTP5 KeyAttribute가 없습니다.

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

namespace ERP.Models 
{ 
    public class CustomerAddress 
    { 
     [Key] 
     public int AddressID { get; set; } 
     public int CustomerID { get; set; } 
     public string Address1 { get; set; } 
     public string Address2 { get; set; } 
     public int CityID { get; set; } 
     public int SateID { get; set; } 
    } 
} 

DataAnnotations 라이브러리가 포함되어 있지만 모두 [OK]이지만 [Key] 특성을 찾을 수 없습니다. 모든 힌트를 높이 평가합니다. 감사!

+2

프로젝트 참조에'System.ComponentModel.DataAnnotations.dll'을 추가해야합니다. Btw. CTP5는 매우 오래되어 쓸모가 없습니다. 최종 버전 인 EF 4.1 RTW로 업그레이드해야합니다. –

+0

@ 라디 슬라브 (멋진 라디슬라프)는 모두 당신이 말한대로 작동합니다. 감사합니다. RTW에 대한 팁을 주셔서 감사합니다. 나는 당신의 코멘트를 답으로 표시하고 싶습니다만, 답으로 답글 대신 게시 할 수 있습니다. – Nestor

답변

1

문제가 다른 곳에서 발생하지 않았는지 확실하지 않았기 때문에 대답으로 먼저 게시하지 않았습니다. 프로젝트 참조에 System.ComponentModel.DataAnnotations.dll을 추가해야합니다.