1
votes

I am building an MVC 3 application with entity framework and I am pulling in information from two different entity models.

Each entity model has been given a custom namespace and each entity model has the table of 'customer'.

However, when I'm generating the partial classes, using the custom tool the table of 'Customer' cant be resolved in that partial classes.

How do I get the tables to resolve to the correct namespaces in that partial classes?

3
Could you give some code examples? I don't really get what you are trying to do - Nick N.
The problem is down to the compiler not being able to have two entity models with tables of the same name from the DBMS. There isn't any code to see - tony
Have a look at this question: stackoverflow.com/questions/5093563/… - Nick N.
That's probably still not what you mean to do, I think you can use custom mapping to map one of the entities to another name. What version of entity framework are you using? - Nick N.

3 Answers

1
votes

If you put your models in separate folders then you can reference the models using {namespace}.Models.{folder name}.{table name}

0
votes

you can use auto mapper tool to fix this problem. you can get this dll from codplex at below link http://automapper.codeplex.com/

0
votes

In entity framework 5 (4.4) I am able to specify the table mapping myself. So when you right click on an entity and choose for table mapping, then you are able to select to what object it should be mapped. You can also map al the properties the way you want them to be mapped.

enter image description here

As shown in the screenshot above, when you change "Maps to Action" (in my case) to some other object it will be mapped to the other one. So you would have 2 different classes with different names in this case. I think you won't get any closer with entity framework.