I am getting a MSDTC error every now then and also specially when I execute my code 1st time. Immediately thereafter the code works fine and then errors out after a while again.
I am trying to save my entity - hardware along with a related entity - server that has a 1:1 relationship.
I am saving my entity - hardware after disabling my validations using "invalidating validation".
It errors out on line with - hardwareContext.SaveChanges below.
Pls let me know if i can provide more details or answer any question. Thanks for your help.
Code:
using (ContextClass hardwareContext = new ContextClass())
{
hardwareContext.Hardwares.Add(hardware);
hardwareContext.Configuration.ValidateOnSaveEnabled = false;
hardwareContext.SaveChanges();
return CreatedAtRoute("DefaultApi", new { id = hardware.HardwareID, serverid = hardware.Server.serverID }, hardware);
}
Error Message:
Exception Message :The underlying provider failed on Open.
** Exception Inner Exception :System.Data.SqlClient.SqlException (0x80131904): Import of Microsoft Distributed Transaction Coordinator (MS DTC) transaction failed: 0x8004d00e(XACT_E_NOTRANSACTION). at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
User contributions licensed under CC BY-SA 3.0