I build asp.net application, for db i use TableAdapter. Select Query
SELECT
U.empID,
U.firstName,
U.lastName,
R.name AS Role
FROM
USER_T AS U
INNER JOIN USER_ROLES_T AS UR ON U.empID = UR.empID
INNER JOIN ROLES_T AS R ON UR.roleID = R.typeID
empId
with constraint primary key
. Employee has many role attributes, it named role.
When I perform request for user data from db:
UsersTableAdapter usersTableAdapter = new UsersTableAdapter();
DataBase.UsersDataTable users = usersTableAdapter.GetUsers();
I get following exception:
Controllers.UI.Login.LoginController|System.Data.ConstraintException: Failed to
enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
If I perform request select-request with any admin program it get
28 Roman Ivanov Admin
28 Roman Ivanov Developer
I understand, this happens because of primary key empId
, how can this problem get solved? How can i remove a primary key from adapter?