Scenario: An attempt to retrieve and move information from one database to another. DB A has some data that I want to get. I want to save it to DB B in a slightly different structure.
DB A I get the use of the model generated by the EDMX database, so it uses a derivative of ObjectContext. DB B I would like to get the code. Therefore, I use the first code / model approach by installing EntityFramework 4.1 through the package manager. So DB B uses a derivative of DbContext
When I try to save information from DB A to DB B, it says:
Test method RoutIT.Irma.Import.Service.Test.ImportIrma2ProductTests.ImportProducts throws an exception: System.ArgumentException: Could not find the conceptual model type for "Some object in DB A EDMX model"
This actually happens when you add a DB B object to the DB B Derived DbContext DbSet property. So the code is similar to
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
{
foreach (FirstPVC pvc in pvcs)
{
this._irmaImport.FirstPVCs.Add(pvc); <--
this._irmaImport.SaveChanges();
}
scope.Complete();
}
}
This happens at the point in the code indicated by the arrow above ("<-")
FirstPVC is a property of DB B at the point of the arrow, which is associated with the lack of a conceptual model for an object related to the context of DB B.
This is strange since I am trying to save DB B in the context of DB B. Why should it take care of DB A.
. DB B Derived DbContext DbSet < > , - DbSet < > , .
- , ? DbContext , , ObjectContext.
, , , :
[EdmEntityTypeAttribute(NamespaceName="Irma2Model", Name="AccessProvider")]
[Serializable()]
[DataContractAttribute(IsReference=true)]
public partial class AccessProvider : EntityObject
{
}