Print Page | Close Window

Same entity type in multiple managers

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2012
Forum Discription: For .NET 4.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=4593
Printed Date: 06-Sep-2025 at 6:54am


Topic: Same entity type in multiple managers
Posted By: smi-mark
Subject: Same entity type in multiple managers
Date Posted: 06-Nov-2013 at 2:27pm
There appears to be a problem when using CodeFirst and sharing the same entity in two managers.

Example:

   ProductAEntities
           Setting

  ProductBEntities
           Setting

When you query for Setting under a typed EntityManager, there is nothing distinguishing between a query for Setting on ProductAEntities vs ProductBEntities.

In the EntityServerQueryInterceptor.GetDataSourceKey() it simply looks for the type, which may exist in multiple Data Sources.

Any suggestions?



Replies:
Posted By: smi-mark
Date Posted: 06-Nov-2013 at 3:48pm
One solution I came up with would be to make all our common types abstract and simply have a blank implementation of them in each model. It isn't ideal, but it would work if that's the only realistic solution.



Posted By: kimj
Date Posted: 06-Nov-2013 at 6:14pm
The ibmmx does actually contain data source key and other information for each entity, and you'll see this entity in each ibmmx.  The problem is that DevForce generally stores metadata keyed by the type, so will only recognize one set of metadata for a specific type.  Another workaround would be to put these models in separate projects and use a different namespace in each for the common entity definition, so that effectively you have two different types.


Posted By: smi-mark
Date Posted: 06-Nov-2013 at 6:18pm
Hi Kim,

These are already in separate projects, but it is structured like this:

Common project:
  Address

Project1:
   Project1Entities has a definition for Common.Address

Project2:
  Project2Entities has a definition for Common.Address

I think if I was to have an Address in each project that inherits from Common.Address that would effectively solve the problem.



Print Page | Close Window