When I run this action every time it increases rating.Likes.
Can I have a little help?
public ActionResult Like(int id)
{
    ApplicationDbContext db = new ApplicationDbContext();
    var rating = db.Ratings.FirstOrDefault(x => x.id == id);
    if (!(rating.RatedFrom.Contains(User.Identity.Name)))
    {
        rating.Likes++;
        rating.RatedFrom.Add(User.Identity.Name); 
    }
    rating.Views--;
    db.SaveChanges();
    return RedirectToAction("Details", db.ImageModels.FirstOrDefault(x => x.id == id));
}
				
                        
1) Create the
RatedFromclass:2) Setup the
RatedFromat yourRatings3) Setup the
RatedFromat youDbContextto be mapped to the Data Base:4) Change the Controller code:
And done! Given that you are using Coding-First. If you are using Database-first you must create the class mapp manually: Mapping to Existing Table in the Database