SqlException: Invalid object name "User"

Hi im getting this error where it says "SqlException: Invalid object name ‘User’. even though i have build the application without errors and checked the application everything except this works, please do give me some suggetsions.

code:

 public async Task<User> Create(User user)
        {
            _context.User.Add(user);
            await _context.SaveChangesAsync();//error happens here
            return user;
        }

>Solution :

Change _context.User.Add(user); to _context.Users.Add(user);

Leave a Reply