c# - Does Entity Designer support many-to-many relationships with duplicate association data? -
package has 1 desktop y , 1 monitor z. package b has 1 desktop y , two monitor z's. want represent relationship in database created entity designer.
there's many-to-many relationship between standardpackage
, standardmachine
(which has desktops, monitors, laptops, etc). every quarter, update our packages, , clients place orders. select package, , when order placed, package's standardmachines
dump data (type, make, model, etc.) newly created machines
.
the problem lies in way entity designer creates junction table standardpackagestandardmachine
relationship. junction table has 2 columns corresponding ids of records on each end of relationship, , primary key junction table combination of 2 ids. so, example in first paragraph, if package a's id 1, package b's id 2, desktop y's id 1, , monitor z's id 2, need is
standardpackageid | standardmachineid ------------------|------------------ 1 | 1 1 | 2 2 | 1 2 | 2 2 | 2
but can't have 2 2/2 records.
is there nice way tell entity designer intend do, create auto-incrementing primary key column junction table? or have resort manually creating junction table , handling association myself?
by way, if knows how rephrase question title, please so.
or have resort manually creating junction table , handling association myself
yes, have. because table not junction table, entity.
the semantics of many-to-many association subtly different want express. 1 record in regular n:m association table expresses "a related b". in your table express "a has instance of b".
the former expression redundant when repeated: "a related b" - ok, knew that. latter isn't: "a has instance of b". there 2 distinct instances, means each instance has identity. identity core concept of entities.
so standardpackagestandardmachine
regular class represents machine instance in package, though it's still 'virtual machine'.
Comments
Post a Comment