2013-02-08 2 views
0

ASP.NET 4.0을 사용하여 웹 응용 프로그램을 개발하고 있습니다. 데이터베이스 SQL Server 2005가 있고 Entity Framework 5를 사용하여 연결하고 있습니다.엔티티 프레임 워크 5 : net40

public class ArchivioClienti : DbContext 
{ 
    public ArchivioClienti() 
     : base("ICAMConnection") 
    { 
    } 

    public DbSet<ClientiProspect> clienti { get; set; } 
}   
[Table("pvw_clienti_prospect")] 
public class ClientiProspect 
{ 
    [Key] 
    public string tipologia { get; set; } 
    public string cod_ppro { get; set; } 
    public string rag_soc { get; set; } 
    public string indirizzo { get; set; } 
    public string cap { get; set; } 
    public string citta { get; set; } 
    public string prov { get; set; } 
    public string nazione { get; set; } 
    public string telefono { get; set; } 
    public string fax { get; set; } 
    public string part_iva { get; set; } 
    public string cod_fisc { get; set; } 
    public string note { get; set; } 
    public string e_mail { get; set; } 
    public string cod_ppro_anag { get; set; } 
    public string cod_vage { get; set; } 
    public string cod_visp { get; set; } 
    public string fonte { get; set; } 
    public string cod_vzon { get; set; } 
    public decimal perc_provv { get; set; } 
    public string flag_stato { get; set; } 
    public string cod_anag { get; set; } 
    public string gg_chiusura { get; set; } 
    public DateTime? data_ins { get; set; } 
    public string cod_canale { get; set; } 

} 

테이블에서 데이터를 가져 오려고합니다. 이것은 실제 테이블이 아니라보기입니다. 내가 LINQ와 쿼리를로드

var result = from u in dbClienti.clienti 
      select u; 

return result.ToList() 

나는 결과 그러나 잘못된 필드 (내가 SQL 서버 관리 스튜디오에서 같은 쿼리를 받도록 같은)의 정확한 번호를 받게 : 첫 번째는 복제 여러 번, 두 번째 동일, 등등.

왜 이런 방식으로 작동합니까? 데이터베이스 뷰를 사용하여 Entity Framework에 문제가 있습니까?

+0

SQL Server 2005 _should_ EF 함께 잘 작동하지만 주류 지원이 2011 년에 끝난 이후로 100 % 작동하는지 확인하는 데 많은 에너지가 필요하지 않습니다. (http://support.microsoft.com/lifecycle/search /default.aspx?sort=PN&alpha=SQL+Server+2005&Filter=FilterNO). –

답변

0

귀하의보기가 올바르게 구성되어 있고 Entity Framework 외부에서 실행될 때 올바른 결과를 반환한다고 가정합니까?

Entity Framework에서 테이블 대신보기를 사용하면 문제가 없습니다. SQL Profiler를 실행하고 쿼리를 실행할 때 E.F가 수행중인 작업을 확인합니다.

+0

나는 그것을 고쳤다! 문제는 [Key] : 나는 'cod_ppro'로 설정해야했습니다. 이제 작동합니다! .. tnx – gorgonzola

관련 문제