I have a problem with entity framework4.1. In which i need to define my connection string at runtime and my business logic call will travel to various sub class to perform insert operation(for insert we are using SP as function import)
Exception occurs only when i implemented transaction.
Exception Detail : The underlying provider failed on Open.
Inner Exception : {"Attempted to access an unloaded appdomain. (Exception from HRESULT: 0x80131014)"}
Can some one help me to solve this problem(implementing transaction separate).
classAddress
{
// Address fields
}
publicclassPersonBL
{
publicbool addPerson(Person person) { EntityConnection objEntityCon = newEntityConnection("my connection string"); using (DBEntity dbContext = new DBEntity(objEntityCon)) { using (TransactionScope transaction = newTransactionScope()) { ObjectParameter id = newObjectParameter("personID", typeof(Int32)); // Calling my Function import to insert person(except address information) // record which return PersonID
dbContext.AddPerson(person.Name, id);
int personID = Convert.ToInt32(id.Value); if (personID > 0 && AddAllAddress(person.AllAddress, personID)) transaction.Complete(); } } }
publicbool AddAllAddress(List<Address> addresses, int personID) { bool result = true; AddressBL addressBL = newAddressBL(); foreach(Address address in addresses) { if (!addressBL.addAddress(address)) // Error occurs at this place. { result = false; } }
return result; } }
publicclassAddressBL
{
publicbool addAddress(Address address) { bool result = true; EntityConnection objEntityCon = newEntityConnection("my connection string"); using (DBEntity dbContext = new DBEntity(objEntityCon)) { // Call imported SP(function import)
}
return result = true; } }
Rakbull
Member
4 Points
3 Posts
Entity framework & Connection string at runtime | Issue in implemention Transaction
Feb 24, 2012 01:33 PM|LINK
Hi All,
I have a problem with entity framework4.1. In which i need to define my connection string at runtime and my business logic call will travel to various sub class to perform insert operation(for insert we are using SP as function import)
Exception occurs only when i implemented transaction.
Exception Detail : The underlying provider failed on Open.
Inner Exception : {"Attempted to access an unloaded appdomain. (Exception from HRESULT: 0x80131014)"}
Can some one help me to solve this problem(implementing transaction separate).
Eg