2016-07-15 2 views
-1

ASP.Net Core 1.0 및 EF Core를 통해 응용 프로그램을 만들고 있습니다. 내 모델과 내 뷰 모델을 AutoaMapper로 매핑했습니다.JsonResult ASP.NET 엔터티 프레임 워크 핵심 오류

SQL:BatchCompleted SELECT [c].[COMP_ID], [c].[AddrCity], [c].[AddrState], [c].[AddrZip], [c].[Address], [c].[CRORoute_DT] FROM [Complaints] AS [c] Core .Net SqlClient Data Provider

: 나는 SSMS 내 SQL 프로파일을 검사 할 때

Error Number:208,State:1,Class:16 Exception thrown: 'System.Data.SqlClient.SqlException' in Microsoft.EntityFrameworkCore.dll CRAMSCore1.Models.CramsRepository:Error: Error getting complaints Microsoft.AspNetCore.Mvc.Formatters.Json.Internal.JsonResultExecutor:Information: Executing JsonResult, writing value.

, 나는 그것이로 데이터베이스를 조회되는 것을 볼 수 있습니까 : 나는 컨트롤러를 만들고를 호출 할 때

, 나는이 오류

내 저장소는 매우 간단 같습니다

public IEnumerable<COMPLAINT> getAll() 
    { 
     try 
     { 
      return _context.Complaints 
       .ToList(); 
     } 
     catch (Exception ex) 
     { 
      _logger.LogError("Error getting complaints", ex); 
      return null; 
     } 
    } 

내 컨트롤러는 다음과 같습니다

[HttpGet("")] 
    public JsonResult Get() 
    { 
     var complaints = _repository.getAll(); 
     var results = Mapper.Map<IEnumerable<ComplaintViewModel>>(complaints); 
     return Json(complaints); 
    } 

답변

1

SQL을 수동으로 실행하면 어떻게됩니까? 이 오류는 JSONResult와는 관련이 없지만 EF를 통해 SQL에서 데이터를 검색하는 것과 관련이 있습니다.

나는 또한 수익이 있어야 할 것 같은데요

return Json(results); 
+0

그것이 EF7이었다 때처럼 내 DBcontext이 작동하지 않습니다 나타납니다. 나는 그것을 디버깅해야 할 것이다 ... – epv