Question

I'm having a problem concerning entity framework and 2 projects within the same solution.

I have 2 projects. project A is coded in Visual Basic and contains the entity framework code. project B is coded in C# and is part of an internal library (i can't make any modifaction to this code)

Thus far i have used the partial classes entity framework generates and incorporated into my own classes inside project A.

But now i need to store data from project B.

One of the possible solutions is creating a dummy class to carry the data when i want to save my data. but doing this creates an extra step when i either want to save or load my data.

Is there a way to save the data i'm overlooking?

Was it helpful?

Solution

One of the possible solutions is creating a dummy class to carry the data when I want to save my data.

Yes - they're called "Data Transfer Objects" (DTOs) and they're commonly used in situations like yours.

If the properties between the classes in A and B are the same, then tools like AutoMapper make life easier by automatically creating a mapping between the two classes.

The drawback, however, is when you have situations where your properties don't map directly, you must figure out how to configure AutoMapper to map between the two classes. If you have to do complex translations, then custom coding gives you the most flexibility.

As a side note, this isn't a cross-language problem as your classes are CLR clases in both languages. THe same issue arises when dealing with two C# projects.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top