c# - Entity Framework DBFirst turns table into association, how to get table access? -


i have dbfirst entityframework 6.1 solution i'm trying generate off of. when add table contains 2 foreign keys table turned 2 associations , can not directly access table anymore. neat navigation in code makes pain in ass delete records table.

is there way prevent behavior , gain direct access table entity?

for example unable remove entry in association because error

the operation failed: relationship not changed because 1 or more of foreign-key properties non-nullable. when change made relationship, related foreign-key property set null value. if foreign-key not support null values, new relationship must defined, foreign-key property must assigned non-null value, or unrelated object must deleted.

for example here how database sees structure.

dbdiagram

here how appears in entity framework. notice corporatedatasharevisible table missing , instead 2 new associations created.

entityframeworkdiagram

the corporatedatasharevisible table should able deleted , added @ changes make seem stop working.

add primary key table has foreign keys. ef uses primary key keep track internally of element. without primary key doesnt know element modified , how send rdbms.

i prefer surrogate keys i.e auto incrementing integers. can add primary key making composite key of both foreign keys


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -