Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9231573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:06:18+00:00 2026-06-18T06:06:18+00:00

This error is driving me crazy. It used to work. Now it doesn’t. Not

  • 0

This error is driving me crazy. It used to work. Now it doesn’t. Not sure what change caused it and I can’t roll back without losing a lot of stuff.

 Unable to cast object of type 'System.Collections.Generic.List`1[Literrater.Models.ranges]' 
 to type 'Literrater.Models.ranges'.

Here’s the model.

public class Comment
{
    [Key]
    public int CommentID { get; set; }
    public int ProjectDocID { get; set; }
    public int UserID { get; set; }
    public string text { get; set; }
    public string quote { get; set; }
    public DateTime DateCreated { get; set; }

    public virtual ICollection<CommentVote> CommentVote { get; set; }
    public virtual ICollection<CommentReply> CommentReply { get; set; }
    public virtual ICollection<CommentReport> CommentReport { get; set; }
    public ProjectDoc ProjectDoc { get; set; }
    public virtual User User { get; set; }
    public ICollection<ranges> ranges { get; set; }
}
public class ranges
{
    public int ID { get; set; }
    public string start { get; set; }
    public string end { get; set; }
    public string startOffset { get; set; }
    public string endOffset { get; set; }


}

Action that throws an error

    [HttpPost, ActionName("Create")]
    public ActionResult Create(Comment comment)
    {
        comment.DateCreated = DateTime.Now;
        comment.UserID = WebSecurity.CurrentUserId;
        db.Comments.Add(comment); //Error here
        db.SaveChanges();
        return Json(comment);

Json being posted.

 {"text":"",
  "ranges":
       [{
            "start":"/p[1]",
            "startOffset":160,
            "end":"/p[1]",
            "endOffset":234
       }],
   "quote":"es. Hadn't they ever heard of potpourri? Each incessant beep, made by the",
   "UserID":"6",
   "ProjectDocID":"1"
 }

Update: Screenshots from old working database
enter image description here
enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:06:19+00:00Added an answer on June 18, 2026 at 6:06 am

    After a couple of hours of replacing one file at a time it appear that my DAL Context file had this fluent API statement.

     modelBuilder.Entity<ranges>().HasRequired(p => p.Comment);
    

    I don’t know why I added it, but commenting it out made the error go away. If someone could explain it that would be sweet.

    Turns out I did it so I could delete the comment, which doesn’t work now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This error is driving me crazy . I tried freenode #emberjs before asking here.
This error is driving me crazy. I'm developing an App Engine Python application. These
This has been driving me crazy for a few days now. I have an
This thing is driving me crazy, and the error is quite meaningless to me:
This is driving me crazy, I just can't find out the problem: I have
Using jboss5.1.x, ejb3.0 This was driving me crazy for two day now: I am
This is driving me crazy i know its a simple error but either i
I am driving myself crazy over what I am sure is a basic error
This is driving me crazy! I keep crashing with this error. Below is my
This error is driving me crazy in eclipse indigo [ERROR] Failed to execute goal

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.