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
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Entity framework & Connection string at runtime | Issue in implemention Transaction
Feb 26, 2012 12:08 AM|LINK
Hello:)
Suspecting that there's something wrong with your machine.config。So plz copy a new one from other's PC with the same version of VS to yours。
Reguards!
Rakbull
Member
4 Points
3 Posts
Re: Entity framework & Connection string at runtime | Issue in implemention Transaction
Feb 27, 2012 04:35 AM|LINK
I tried this code in another machine still no change in error, So i think this error may not related to my machine.config.
Please any other idea or suggestion.
Madhuban - M...
Member
34 Points
7 Posts
Re: Entity framework & Connection string at runtime | Issue in implemention Transaction
Mar 28, 2012 09:28 PM|LINK
Hi Rakbul , If you are still facing this issue , I will recomend you open microsoft support Incident for this issue.
nitin403
Member
12 Points
10 Posts
Re: Entity framework & Connection string at runtime | Issue in implemention Transaction
May 05, 2012 12:21 PM|LINK
Try following code.