entity framework - "Multiple object sets per type are not supported" error when trying to map data from two different tables to a single domain type -


i new entity framework , trying setup code first following table structure

table: client

1. clientid int 2. name varchar(200) 3. company varchar(200) 

table: erpconnection

1. clientid int (foreign key client) 2. server varchar(100) 3. username varchar(100) 

table: erpadminconnection

1. clientid int (foreign key client) 2. server varchar(100) 3. username varchar(100) 

as can see there 1 one relationship between client->erpconnection , client->erpadminconnection. (note: did not design tables,but have use is)

as can see not need 2 different types denote erp , erpadmin.

so want create context this

public class clientcontext: dbcontext {     public dbset<client> clients{ get; set; }     public dbset<connection> erpconnection { get; set; }     public dbset<connection> erpadminconnection { get; set; }     public clientcontext(string connectionstring)     {         this.database.connection.connectionstring = connectionstring;     } } 

however, when ran sample code got error " multiple object sets per type not supported. "

how setup classes above dbcontext can used without having define new type erpadminconnection?

it's not possible. internally, database entity mappings one-to-one, , each entity must matched class unique name.

ef code first, how register same table name different schema?


an option have base class , 2 derived classes (which won't need defined within them if they're otherwise identical) , use tpc inheritance.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -