-1

Conferenceこのテーブルに問題があります。エラーは次のとおりです。

無効な列名 'Conference_ConferenceID'

ここに画像の説明を入力

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;

        }
    }
}
4

1 に答える 1

0

コードとDBの間に不一致がある場合、コードがDB内の列を見つけることを期待しているが、そこに存在しないという意味で、このエラーが発生します。これは、コードの変更に合わせて DB が更新されていない場合に発生します。そのエラーが発生したときにヒットしているデータベースを確認することをお勧めします。おそらく、期待どおりの場所ではありません。

于 2013-05-16T18:23:49.923 に答える