First of all, please note I´ve been checking other questions like this: Unable to update the EntitySet - because it has a DefiningQuery and no <UpdateFunction> element existUnable to update the EntitySet - because it has a DefiningQuery and no <UpdateFunction> element exist
but none of them worked for me unfortunately
I am getting the following error message, that happens when there is no primary key on the table:
DbUpdateException was unhandled
Additional information: Unable to update the EntitySet 'Employee' because it has a DefiningQuery and no element exists in the element to support the current operation.
I am getting the error when executing:
...
ctx.Employee.Add(employee);
ctx.SaveChanges();
...
However, my table has the primary key defined:
CREATE TABLE [dbo].[Employee] (
[Id] INT NOT NULL,
[name] VARCHAR (50) NOT NULL,
[surname] VARCHAR (50) NOT NULL,
[password] VARCHAR (50) NOT NULL,
[dni] VARCHAR (50) NOT NULL,
[phone] VARCHAR (50) NOT NULL,
[salary] VARCHAR (50) NOT NULL,
[email] VARCHAR (50) NOT NULL,
[address] VARCHAR (50) NOT NULL,
[postcode] VARCHAR (50) NOT NULL,
[city] VARCHAR (50) NOT NULL,
[province] VARCHAR (50) NOT NULL,
[admin] BIT NOT NULL,
PRIMARY KEY CLUSTERED ([Id] ASC)
);