How to Avoid Duplicated Metadata Entries in ORM Model

3 posts, 0 answers
  1. Jeff
    Jeff avatar
    10 posts
    Member since:
    Oct 2010

    Posted 25 Jun 2013 Link to this post

    Hi All!

    I have a question about the Open Access Model.  I have two separate models in the same project, both of which contain the same reference table.

    When I compile the project, I get a "Duplicated Metadata entries found for type PartMaster. Please use only one way of mapping." comiler error.  It seems that the Enhancer is throwing this error.

    I can see a couple of solution paths, but I am not sure how to embark on either, so some guidance would be appreciated.  Here are the solution paths:
    Option 1: Create a Fluent Model that tells the Enhancer to IGNORE the reference table in question.  I have found documentation that tells me that the presence of a Fluent Model will tell the Enhancer to only follow the explicitly mapped entities.  This is not what I want, as I want to indicate that the reference table entity should be ignored.

    Option 2: Add some logic to the models to tell each that the reference table is the same entity.  Not sure how to do this... Is there a way to tell the model that the entity is the same persisted entity in another model.

    Any ideas would be much appreciated.

    j.
  2. Jeff
    Jeff avatar
    10 posts
    Member since:
    Oct 2010

    Posted 25 Jun 2013 Link to this post

    Ok, after some investigation, I have found a solution for having two ORM Domain Models in the same project.

    Other than separating the domain models into separate libraries, the manner that worked was to rename the reference entity in one of the models to a new name.  This forces the Enhancer to treat the object as a separate mapping.

    What would be really useful, is to have an option on the designer to indicate that a model references an entity in another model for mapping purposes, particularly if the reference is a ReadOnly reference anyway.

    j.
  3. DevCraft banner
  4. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 28 Jun 2013 Link to this post

    Hello Jeff,

    You have found the right solution. At the moment it is not allowed one class to take part in two models, so renaming one of the classes is the easiest option.

    Regards,
    Alexander
    Telerik
    OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
Back to Top