Reputation: 24053
I have two tables like this:
Table1(id, name)
Table2(id_of_table_1, code)
I don't need an entity for Table1 or Table2, but one entity for both together:
class Merge{
public virtual long id{get;set;}
public virtual string name{get;set;}
public virtual string code{get;set;}
}
How can I load the tables to the edmx so that they will considered as one?
I don't have any control on the database and I can't create tables or views.
Upvotes: 4
Views: 198
Reputation: 10941
In short, you need to do this:
For a more detailed explanation, you can have a look at this blog post.
Upvotes: 1
Reputation: 8829
I think this is what you're lookig for: How to: Define a Model with a Single Entity Mapped to Two Tables
Upvotes: 1
Reputation: 364249
You are looking for advanced mapping called Entity splitting.
Upvotes: 2
Reputation: 63190
Create a function inside your Merge class that writes the properties of your class to the appropriate Table1 and Table2 EDMX objects. Your Merger
class should have references to those EDMX objects as internal variables. So this class is like a wrapper for your 2 table objects.
Upvotes: 0