0

I have 5 different edmx files, each contains many tables (40 approximately).
Now I wat to add same type reference property for some tables that lays on those diefferent edmxs. For example, Assume in edmx1 I have Worker entity, in edmx2 I have Customer entity, in edmx3 I have Supplier entity and so on. Now I want to add reference to Location entity to Worker, Customer and Supplier. I can add the Location table to each edmx and make code duplication. But in my case, I have many common entities and not just location. Actually, I prefer to saperate all the common entities to a different edmx and do something like "inheritance" to each other edmx that has entities with references to common entity. Is such thing possible? If so - how? If not - what is a common solution to such case?

Naor
  • 23,465
  • 48
  • 152
  • 268

1 Answers1

0

No. If you are using EDMX files than each file is self contained.

Reuse of types has very limited support in EF when working with EDMX. First of all it is not supported in designer. It is also supported only in CSDL. So it means that you can have multiple CSDL parts (entity definition) where one CSDL document can make relations to entities from another CSDL document (but this relation can be only unidirectional) but you can have only one SSDL (database definition) and MSL (mapping definition) document.

At the moment each your EDMX file represents separate CSDL, MSL and SSDL document so it cannot be easily converted to that scenario.

This is good scenario for code mapping (no EDMX).

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
  • All the edmx's are using the same database. In addition, I need only unidirectional relation (Location shouldn;t know about Customer for example). What to search in order to find how implement this using CSDL? What do you meen by code mapping (no EDMX)? – Naor Apr 13 '12 at 12:51
  • The link provides the way how to use it (it is just more complicated way to use one huge EDMX file). Code mapping = code first. – Ladislav Mrnka Apr 13 '12 at 12:53
  • Thanks! Does this method allow putting each edmx in saperate project? – Naor Apr 13 '12 at 14:49
  • No. EDMX consist of three parts - CSDL, MSL, SSDL. This method expects that you are not using EDMX but those parts directly - you will have separate CSDL for every your "EDMX" but only single MSL and SSDL concatenated from all of your EDMXes. – Ladislav Mrnka Apr 13 '12 at 15:04