i want to make a relationship between aspnetusers and table uservotes.i did this relationship according to docs but whent i want to add data to uservotes and savechanges the compiler stops in savechanges line.does anyone khow the problem?thank you for any help.
public class UserVote
{
[Key]
public int VoteId { get; set; }
public string ClientId { get; set; }
public int Hpid { get; set; }
public int Hplid { get; set; }
[ForeignKey(nameof(Hpid))]
public TableHp TableHp { get; set; }
[ForeignKey(nameof(Hplid))]
public TableHpl TableHpl { get; set; }
[ForeignKey(nameof(ClientId))]
public ApplicationUser Applicationuser { get; set; }
}
public class ApplicationUser:IdentityUser
{
public virtual List<UserVote> UserVotes { get; set; }
}
public async Task<int> AddvoteForHp(int hpid, string userid)
{
UserVote vote = new UserVote()
{
Hpid = hpid,
ClientId = userid
};
await _context.AddAsync(vote);
await _context.SaveChangesAsync();
var user = await GetPersonByIdAsync(hpid);
user.Like++;
_context.TableHps.Update(user);
await _context.SaveChangesAsync();
return user.Like;
}