Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework - the edm type is mapped more than one

I have a simple Entity data model (using VS2010) that I reverse engineered from a simple SQL Server database that contains three unrelated tables.

I try to save data to the database using the following code:

var dbOptions = new ARC_WHENTECHModel.TEMP_LANDED_WHENTECH_OPTION_POSITION();

//first map fields required for standard di processing
dbOptions.OPTION_POSITION_SOURCE_ID = webSvcOption.TDR + "_" + webSvcOption.CNTR + "_" + webSvcOption.CRV;
dbOptions.INSERTED_DT = DateTime.Now;
dbOptions.CURRENT_IND = "Y";

//now map the data we've pulled from the web service call
dbOptions.CA = webSvcOption.CA;
dbOptions.CDTP = webSvcOption.CDTP;
dbOptions.CMD = webSvcOption.CMD;
dbOptions.CNTR = webSvcOption.CNTR;
dbOptions.CPP = webSvcOption.CPP;
dbOptions.PDTP = webSvcOption.PDTP;
dbOptions.SPR = webSvcOption.SPR;
dbOptions.TDR = webSvcOption.TDR;


context.AddToTEMP_LANDED_WHENTECH_OPTION_POSITION(dbOptions);
context.SaveChanges();

but I get the following exception:

An EdmType cannot be mapped to CLR classes multiple times. The EdmType 'RDLMServiceTier.TEMP_LANDED_WHENTECH_FUTURES_POSITION' is mapped more than once.

at the following line (base.AddObject) within the designer.cs code:

[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
public void AddToTEMP_LANDED_WHENTECH_OPTION_POSITION(TEMP_LANDED_WHENTECH_OPTION_POSITION tEMP_LANDED_WHENTECH_OPTION_POSITION)
{
    base.AddObject("TEMP_LANDED_WHENTECH_OPTION_POSITION", tEMP_LANDED_WHENTECH_OPTION_POSITION);
}

Could anyone please advise what I may be doing wrong? I don't have much experience with Entity Framework (it's always "just worked" in the past). I guess the next step may be to reflect the EF code but that's going to be quite tricky because I'm debugging on a remote machine that I don't have great scope for installing extra software.

Thanks

Rob.

like image 683
Rob Bowman Avatar asked Nov 13 '22 15:11

Rob Bowman


1 Answers

Gert answered this correctly - there was another copy of the model file present.

like image 91
Rob Bowman Avatar answered Nov 15 '22 11:11

Rob Bowman