2013-05-16 2 views
-1

Conference 테이블에 문제가 있습니다. 오류 :Entity Framework : 잘못된 열 이름

잘못된 열 이름 'Conference_ConferenceID'

enter image description here

namespace MeetingBoard.Model 
{ 
    using System; 
    using System.Collections.Generic; 
    using System.ComponentModel.DataAnnotations; 
    using System.Linq; 
    using System.Web.Script.Serialization; 

    using MeetingBoard.Model.Helpers; 
    using System.ComponentModel.DataAnnotations.Schema; 
    /// <summary> 
    /// A model of the Conference entity. Contains functionality to serialize the entity to JSON as well. 
    /// </summary> 
    public class Conference 
    { 
     [Key] 
     public int ConferenceID { get; set; } 

     public string Title { get; set; } 
     public string Content { get; set; } 
     public int CreatorID { get; set; } 

     public string Location { get; set; } 
     public DateTime SubmissionDate { get; set; } 


     [ForeignKey("CreatorID")] 
     public virtual User Creator { get; set; } 

     public int[] RelatedProjectsIDs { get; set; } 
     public virtual ICollection<ProjectTag> RelatedProjectTags { get; set; } 

     public DateTime CreatedOn 
     { 
      get { return (this.dateCreated == default(DateTime)) ? DateTime.UtcNow : this.dateCreated; } 
      set { this.dateCreated = value; } 
     } 
     private DateTime dateCreated = default(DateTime); 

     public virtual ICollection<Group> RelatedGroups { get; set; } 

     public Conference() 
     { 
      RelatedGroups = new List<Group>(); 
     } 


     /// <summary> 
     /// Generates an object that can be serialized by the JSON serializer of MVC 
     /// </summary> 
     /// <param name="happening">An Conference.</param> 
     /// <returns></returns> 
     public static Object ToJsonObject(Conference conference) 
     { 
      int[] project_ids = conference.RelatedProjectTags.Select<ProjectTag, int>(pt => pt.ProjectID).ToArray(); 



      return new Conference_JSON 
      { 
       id = conference.ConferenceID, 
       title = conference.Title, 
       Content = conference.Content, 
       created_timestamp_UTC = Util.DateTimeToMilliTimeStamp(conference.CreatedOn), 
       SubmissionDate = conference.SubmissionDate, 
       Location = conference.Location, 

       creator_avatar = conference.Creator.Avatar, 
       creator_fullname = conference.Creator.Name, 
       creator_id = conference.Creator.UserID, 

       project_ids = project_ids, 

      }; 
     } 
     /// <summary> 
     /// Instantiates a new Conference object based on the json data. 
     /// </summary> 
     /// <param name="json_data">The json data needs to have the structure as specified in the private Conference_JSON object.</param> 
     /// <returns>A new Conference object. The related projects are referenced using an integer array containing project ids.</returns> 
     public static Conference FromJson(String json_data) 
     { 
      JavaScriptSerializer serializer = new JavaScriptSerializer(); 
      Conference_JSON conference_object = serializer.Deserialize<Conference_JSON>(json_data); 

      return FromJsonObject(conference_object); 

     } 

     /// <summary> 
     /// Instantiates a new Conference object based on the private Conference_JSON object. 
     /// </summary> 
     /// <param name="json_data">The object needs to be an instance of the private Conference_JSON object.</param> 
     /// <returns>A new Conference object. The related projects are referenced using an integer array containing project ids.</returns> 
     public static Conference FromJsonObject(Object conference_object) 
     { 
      Conference_JSON conference_json = (Conference_JSON)conference_object; 

      Conference conference = new Conference 
      { 
       ConferenceID = conference_json.id, 
       Title = conference_json.title, 
       Content = conference_json.Content, 
       RelatedProjectsIDs = conference_json.project_ids, 
       Location = conference_json.Location, 
       SubmissionDate = conference_json.SubmissionDate, 

      }; 
      return conference; 
     } 

     /// <summary> 
     /// Defines the structure of the json objects that ar communicated to and from the Frontend. 
     /// </summary> 
     private class Conference_JSON 
     { 
      /// <summary> 
      /// The Conference identifier. 
      /// </summary> 
      public int id; 
      public string title; 
      public string Content; 

      /// <summary> 
      /// An numeric representation of the time, in milliseconds from Unix Epoch, UTC timezone. 
      /// </summary> 
      public double created_timestamp_UTC; 

      public string creator_fullname; 
      public int creator_id; 
      public string creator_avatar; 

      /// <summary> 
      /// Related projects. 
      /// </summary> 
      public int[] project_ids; 
      public string Location; 
      public DateTime SubmissionDate; 

     } 
    } 
} 
+0

코드 우선 또는 DB 우선 오류는 어디에서 던져 집니까? SSMS 또는 VS? –

+0

일반적으로 데이터베이스에서 일치하는 열을 찾을 수없는 경우 이러한 오류가 발생합니다. 해당 테이블에서 열 이름을 확인하는 것이 좋습니다. –

+0

이것은 컴파일 또는 런타임 오류입니까? –

답변

0

코드와 DB 사이에 불일치가있을 때 내가 의미에서이 오류를 얻을 코드는 DB에서 열을 찾을 것으로 예상하지만 거기에는 존재하지 않습니다. DB에서 코드의 변경 사항과 일치하도록 업데이트되지 않은 경우 발생합니다. 그 오류가 발생했을 때 맞은 데이터베이스를 살펴볼 것을 권하고 싶습니다. 아마도 당신이 기대하는 곳을보고 있지 않을 수도 있습니다.

관련 문제