1

I have a database in TSQL and I use ADO.NET Entity Framework from .NET 3.5 to create the matching entities.

In the database the relationships are not modeled, but in each table involved in a relationship there is a field representing the foreign key to another table's primary key.

For instance (assume a Product can have just one category):

Product ( ProdId(PK), ProdName, CatId(FK))

Category (CatId(PK), CatName)

This way of course there is no referential integrity constraint.

In my application I generate the EF entities from the database and then I add the relationships and their mapping by hand. Everything goes smooth except for the one-to-many relationships.

The mapping specified for the many-to-many relationships (through association table) do not give any kind of error, those specified for the one-to-many

Error 3007: Problem in mapping fragments :Column(s) [foreign_key] are being mapped in both fragments to different conceptual side properties.

Now I checked the mapping, I changed cardinality and directions but still it does not work.

I read in the internet that I should remove the foreign keys but then, how can I map the values in the database? Is there any other solution?

Important: I cannot use .NET 4.0 I have to stuck with .NET 3.5

CiccioMiami
  • 8,028
  • 32
  • 90
  • 151
  • Possible duplicate: http://stackoverflow.com/questions/1369656/getting-error-3007-when-i-add-my-entity-model – Gert Arnold May 09 '12 at 20:24
  • I don't think it is a duplicate, in my case the FK is also present in the database and I cannot remove it from my EF entities – CiccioMiami May 11 '12 at 10:13

0 Answers0