Fluent Mapping Problem: Separating MetadataSource from Entities

4 posts, 0 answers
  1. gfkrt
    gfkrt avatar
    2 posts
    Member since:
    Sep 2008

    Posted 03 Mar 2011 Link to this post


    we are using the fluent mapping api to map our entities to the database.

    All of our mapped entities live in an assembly "Entities". This assembly should not have any references to telerik.
    Our Fluent Mapping Code lives in another assembly "Mappings". Here are references to telerik ok.

    We integrated the enhancer into both Project-Files. But after building the VisualStudio Solution the "Entities" assembly is not enhanced.

    Is there a way to separate Entities from Mappings with the Fluent Mapping API? How do we need to tweak the enhancer to support our design?

    In case of having the entities and mappings in the same assembly the enhancing works.

    Kind regards.
  2. Serge
    Serge avatar
    375 posts

    Posted 08 Mar 2011 Link to this post

    Hi gfkrt,

     Our design is that you need to keep the FluentMetadataSource and entity classes in the same project, as the FluentMetadataSource servers as a link between the mapping and the enhancer. 

    As you have to enhance your classes you absolutely need to link your Entities project with at OpenAccess (meaning that you have to have the OpenAccess.targets include in the project file, this is actually including the Enhancer task that is ran after build). 

    The point is in order to use the enhancer task and enhance your model automatically you need to have the source and entities in the same project, if you want you could manually enhance the assembly with the enhancer however enhancing an assembly without references to OpenAccess would add the necessary references either way. 

    I am afraid, that this is a limitation to using OpenAccess that will most likely not be changed in the near future. I hope this was helpful, do not hesitate to let us know if you face further trouble.

    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. DevCraft banner
  4. Diego
    Diego avatar
    8 posts
    Member since:
    May 2012

    Posted 16 Oct 2012 Link to this post

    This question was specific to fluent mapping (which i imagine works the same as code-only approach) but for the sake of clarity, does this also apply to code-only approaches?

    I'd like to have my POCO/Entity classes in one library that has no knowledge of any Telerik component (except the post-processing "Enhancer" utility via msbuild target).  And then in a separate assembly I'd like to have the mapping configuration MetadataSource class that refers to the POCO/Entity class assembly.

    Is this possible with code-first approach? I know EF supports this but from the documentation it seems like OA does not... Are there any viable work-arounds/hacks to accomplish this separation of dependencies? I'm thinking maybe a separate project that is configured to ONLY build during CI/automated builds, has output directory set to override those binary files of the original  DTOs class assembly, and that uses Linked Files to refer to the same CS files. This "shadow" project would have the references to Telerik dll's needed at compile-time...  I don't know.. some work-around that could be made repeatable via build scripts/msbuild/TeamCity...
  5. PetarP
    PetarP avatar
    754 posts

    Posted 22 Oct 2012 Link to this post

    Hi Diego,

     I am afraid that I might be missing the point here. Why would you want to be mapping any classes that will be acting like POCO? Providing mapping for them would essentially mean that they will be part of the OpenAccess model and they will not really be Pocos then.

    Kind regards,
    the Telerik team
    Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
Back to Top