This is a migrated thread and some comments may be shown as answers.

Fluent Mapping Problem: Separating MetadataSource from Entities

3 Answers 112 Views
Design Time (Visual Designer & Tools)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
gfkrt
Top achievements
Rank 2
gfkrt asked on 03 Mar 2011, 04:03 PM
Hello,

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.

3 Answers, 1 is accepted

Sort by
0
Serge
Telerik team
answered on 08 Mar 2011, 06:46 PM
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.

Greetings,
Serge
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!
0
Diego
Top achievements
Rank 1
answered on 17 Oct 2012, 12:47 AM
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...
0
PetarP
Telerik team
answered on 22 Oct 2012, 02:53 PM
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,
Petar
the Telerik team
Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
Tags
Design Time (Visual Designer & Tools)
Asked by
gfkrt
Top achievements
Rank 2
Answers by
Serge
Telerik team
Diego
Top achievements
Rank 1
PetarP
Telerik team
Share this question
or