开发者

How To Remove Foreign Key Reference In Entity Framework

开发者 https://www.devze.com 2022-12-17 14:23 出处:网络
I\'m updating my model which is built by entity framework. I removed a entity from the designer and then there pops up a error said \"Foreign key constraint \'FK_Table1_Table2\' ... no mapping specifi

I'm updating my model which is built by entity framework. I removed a entity from the designer and then there pops up a error said "Foreign key constraint 'FK_Table1_Table2' ... no mapping specified for the table Table2. Now I really don't want to map Table2 into entities. What should I do to clear the edmx and avoid such error? Ca开发者_如何学编程n I just map the foreign key in Table1 into a int32 field? Thanks!

I'm using EFv1.


I've found the Entity Framework designer leaves a lot to be desired so I found the best way is to edit the .edmx by hand.

The .edmx file contains 3 main sections, one which represents the storage model (database), one which represents the conceptual model and one section which represents the mapping between the two models

If I understand correctly, you have removed Table2 from the conceptual model and so you should remove anything related to it in the conceptual side of the EDMX. Chances are table 1 will still have an association to table 2 that you need to delete. Unfortunately manual edits to the .EDMX file will be overwritten if you ever use the designer to regenerate the model.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号