ASP.Net MVC를 배우는 데 많은 시간을 할애하여 Visual Studio 2010 Professional에 MVC 4를 설치했습니다.Entity Framework 4.1을 설치 한 후에도 RelatedTo 특성이 인식되지 않습니다.
http://www.luisrocha.net/2010/11/creating-composite-keys-using-code.html
을하지만 RelatedTo 속성은 비주얼 스튜디오에 의해 발견되지 않은 :이 예제를 연습했다. this question에서이 문제는 Entity Framework 4.1이 설치되지 않아 발생할 수 있습니다. 난 의 버전 번호를 확인 System.Data.Entity.dll 그리고 그것은 버전 4.0.0.0, 런타임 버전 v4.0.30319 준. 그래서 내 컴퓨터에 설치되어있는 EF 4.0 버전이 될 것 같습니다. 나는 이것에 틀릴지도 모른다. .. 누군가 만일 누군가 그렇다면 나를 교정해라.
나는 here에서 EF 4.1을 다운로드하고 설치되어 있지만 System.Data.Entity.dll의 버전 번호는 변경하지 않는 것 같습니다과 RelatedTo 속성은 여전히 작동하지 않습니다. 누구나 설치에 어떤 문제가 있으며 어떻게 해결할 수 있는지 알고 있습니까?UPDATE :
this site에 지시하고 콘솔이 설치 말했듯이 내가 nuget 사용하는 엔티티 프레임 워크를 설치 EntityFramework 5.0.0-RC하지만 System.Data.Entity.dll의 버전은 변경되지 않은 것으로 보입니다.
아니요, Intellisense에서 포함시키지 않았기 때문에 System.Data.Entity을 사용하여 을 사용하지 않았습니다. 나는이가 키 및 열 특성이 요구 되었기 때문에 System.ComponentModel.DataAnnotations.Schema를 사용 System.ComponentModel.DataAnnotations 및 을 포함했다. Intellisense는 "RelatedTo '에 대한 클래스 생성"을 추가하고 을 추가하면 System.Data.Entity를 사용하여이 변경되지 않습니다.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
namespace Example
{
public class PlaylistTrack
{
[Key, Column(Order = 1)]
public int PlaylistId { get; set; }
[Key, Column(Order = 2)]
public int TrackId { get; set; }
[RelatedTo(ForeignKey = "PlaylistId")]
public Playlist Playlist { get; set; }
[RelatedTo(ForeignKey = "TrackId")]
public Track Track { get; set; }
}
}
당신은'당신의 파일에 System.Data.Entity'을 사용 있나요? – diaho
여기에 샘플 코드를 넣을 수 있다면 더 좋습니다. 기사에 대한 링크가 끊어져도 그 질문은 여전히 가치가 있습니다. –
@Jayantha 깨진 링크가있는 경우 유용한 질문에서 코드를 찍은 점. 코드를 추가했습니다. 감사. – BruceHill