EntityFramework mapping fragments issue

706 Views Asked by At

I am working on an API web project, in ASP.net, and on the recommendation of several stackoverflow users, with a description of my problem, I have decided to use EntityFramework.

Work on a database already created, and formed, with all relationships. I have already generated all the corresponding entities, and do the first sql, to get a small example ql that will return all the data of a given table.

But when I get the query and execute it, I get the error 3002 with the following description:

error 3002: Problem in mapping fragments starting at line 12441:Potential runtime violation of table propuestaMarca's keys (propuestaMarca.marca, propuestaMarca.propuesta): Columns (propuestaMarca.propuesta, propuestaMarca.marca) are mapped to EntitySet propuestaMarca's properties (propuestaMarca.propuesta.cod_propuesta, propuestaMarca.marca.cod_marca) on the conceptual side but they do not form the EntitySet's key properties (propuestaMarca.marca.cod_marca, propuestaMarca.propuesta.cod_propuesta, propuestaMarca.propuesta.empresa).

When I review the .emdx model, I see the following:

enter image description here

The table propuestaMarca does not exist in the model. It is not exported correctly

enter image description here

When I review the .emdx model, I see the following:

The proposed tableBrand does not exist in the model. It is not exported correctly.

I have searched for information about error 3002, and I have found that removing a certain primary key from one of the two tables solves the problem, and had tried to eliminate the primary Empleado key in the propuesta table, but it has not worked. enter image description here

1

There are 1 best solutions below

3
On

This error can also occur when the primary key is made by the combination of more than one attribute (composite key). It looks like you have two "keys" in the propuesta table.

From the error message above:

(propuestaMarca.propuesta, propuestaMarca.marca) -> 2 columns

are mapped to EntitySet propuestaMarca's properties

(propuestaMarca.propuesta.cod_propuesta, propuestaMarca.marca.cod_marca) -> 2 columns

on the conceptual side but they do not form the EntitySet's key properties

(propuestaMarca.marca.cod_marca, propuestaMarca.propuesta.cod_propuesta, propuestaMarca.propuesta.empresa). -> 3 columns

So I think you should check the mapping.