asp.net mvc - Entity Framework - stange behaviour -


i have 3 simplest tables:

http://magicscreenshot.blob.core.windows.net/screenshots/udywngovqem.jpg

and relationships among them:

http://magicscreenshot.blob.core.windows.net/screenshots/ztk28gbgkec.jpg

if create new project 0 , create entity model (from db) receive correct ef model:

http://magicscreenshot.blob.core.windows.net/screenshots/zzg8gpzxfke.jpg

but when try same real project - created ef model strange

http://magicscreenshot.blob.core.windows.net/screenshots/wfkgc8vbdu8.jpg

as can see, created new entity "sectionsite" relationship site , no relationship section. why happened , how fix it?

i able replicate if added in section , sectionsite table independently of adding site table. creates link following link.

broken edmx model

to resolve missmatch of identity can either.

  1. remove , re-add site, section, , sectionsite @ same time.

or

  1. right click "add new association" between site , sectionsite , un-check "add foreign key properties 'section' entity."

add association

  1. then need select created relationship, properties -> referential constraint , update meet fk relationship.

modify referential constraint

  1. once happy, right click , validate model , should work?

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -