mapping Properties in Entity Framework without PK? -


i tried create ef-model(vs2010, .net4) 3 tables, each table pk called sync_id.

table_head: (sync_id (pk), grid_id int, serialnumber int, year int)

table_point: (sync_id (pk), grid_id int, serialnumber int, year int,point_number int)

table_plant: (sync_id (pk), grid_id int, serialnumber int, year int,point_number int,plant_number int)

associations: table_head "1 many" table_point "1 many" table_plant

as can see grid_id, serialnumber, year of table_head should mapped grid_id, serialnumber, year of table_point

and grid_id, serialnumber, year of table_point should mapped grid_id, serialnumber, year,point_number

my first approach use grid_id, serialnumber, year grouped pk, violation of condition.

so way use sync_id pk. how possible map other field described above? can map pk_columns?

hope have ideas me. other approaches welcome, . best regards !

other approach create correct database structure!!!

you have sync_id pk use fk in dependent entity instead of doing mess have described. has nothing in common correct db architecture. point of relational database minimize data duplicity copy data first table dependent tables. moreover:

  • if table_head doesn't have unique index grid_id, serialnumber, year cannot principal entity of one-to-many relation
  • even if has unique index doesn't matter because ef doesn't support unique indices yet must primary key participate principal entity in association

you should read database normalization.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -