Removing navigation properties from POCO classes in Entity Framwork

I use the created POCO and Entity Framework classes.

To make the code less complicated, I try to remove all navigation properties from the code, while preserving the foreign key constraints in the database (navigation properties do more harm than good for us).

If I remove them manually from the POCO classes, I get the following error:

The UserEntity object type is not part of the model for the current context.

If I try to remove them from the .edmx file, I get the following error:

Error 3 Error 3015: problem with displaying fragments starting with lines 479, 562: restriction of the foreign key 'fk_StorageContracts_User1' from the StorageContract table (OwnerUserID) to the User (ID) table :: Inadequate mapping: the foreign key must be mapped to some AssociationSet or EntitySets involved in the association of foreign keys on the conceptual side.

Is there a way to remove navigation properties from POCO classes without removing the corresponding FK?

+5
source share
1 answer

I know this is old, but since there is still no answer, I thought I would try:

EF 4.0, , , , xxxModel.tt. , , -. , :

public List<NavDataX> NavDataXs
{
    get; set;
}

, , . , EDMX .

+1

All Articles