we learning entity framework 6.1 (from nuget) move away linq2sql. have small handful of tables associate 2 separate tables shown below.
ef6 database first generation
db diagram:

schema overview:

when in visual studios, blank class library, doing database first ef6 edmx file, diagram generates tablea , tablec -- tableb not generated.

visual studios view:

you can see tablea , tablec created. technically tableb should have been created, because want able manage references.
the association between , c shown in diagram:

i feel missing option, or misunderstanding key concept of entity framework. idea how have missing tableb generated t4? edmx file show it, reason doesn't generated .cs file 2 properties indicating relationship.
the primary reason need this, extended ef6 t4 template add factory patterns match our existing models. because doesnt generate class tableb, dont autogenerated code looking for.
thoughts / suggestions? thanks.
weak entities or join tables not generated ef, need configure relationships manually thru fluent api or using data annotations
as stated on microsoft's website: under relationship's convention:
note: if have multiple relationships between same types (for example, suppose define
person,bookclasses,personclass containsreviewedbooks,authoredbooksnavigation properties ,bookclass containsauthor,reviewernavigation properties) need manually configure relationships using data annotations or fluent api. more information, see data annotations - relationships , fluent api - relationships.
refer link more information
updated
a workaround work in case of edmx ( cost maintenance) follows:
- remove foreign keys join table in database
- update edmx database
- recreate foreign keys in join table
this workaround work long not update model database again.
recommended solution, keep generated edmx , learn more how use crud operation case using following links reported "helpful" user '@traviswhidden'
Comments
Post a Comment