I have a legacy table containing employee name and employee id. Now the employee id is in char because it can hold values starting with an alphabet. Employee id is the only unique field available in the table.
Now I am using a view to capture the data from the table (It is in a separate database). But my entity framework is refusing to identify the view due to the lack of int primary key.
Any solution to this would be highly appreciated as I can not touch the legacy table.
But my entity framework is refusing to identify the view due to the lack of int primary key.
I doubt it. The EF supports strings as PKs.
But views, of course, can't have PKs at all. Which means you have to do some extra work when using them with the EF, especially if you make them updatable. Here's how.
Create another column that is an int and use that as the primary key. The business users, don't need to know about that key.
My guess is the end application uses an Employee Id with charters. Like first and last initial plus hire date, something like DB012210.
How the table is done internally won't matter to the calling application so you can add another field as the real primary key which is an int. Then just put a unique constraint on the current EmployeeId, but not really use it as the primary key.