2

TransactionScope throwing exception. I am using ASP.NET Core with Core 3.0.

I get following issue locally on Windows: "This platform does not support distributed transactions."

I would like to sync two databases and would like to use TransactionScope to get a consistent state in both databases.

When I deploy it to Azure using AppService and Azure Sql it works fine.

Normally it should work when I check this link with .net core 3.0. https://docs.microsoft.com/de-de/dotnet/api/system.transactions.transactionscope?view=netcore-3.0

Hope somebody can help me.

using (var scope = new TransactionScope())
{

   -- database1
   using (SqlConnection connection = new SqlConnection(connectionString_DB1))
   {
      using (System.Data.SqlClient.SqlCommand cmd = connection.CreateCommand())
      {
         ....
         connection.Open();
         result = cmd.ExecuteNonQuery();
      }
   }

   --database2
   using (SqlConnection connection = new SqlConnection(connectionString_DB2))
   {
      using (System.Data.SqlClient.SqlCommand cmd = connection.CreateCommand())
      {
         ....
         connection.Open();
         result = cmd.ExecuteNonQuery();
      }
   }

   scope.Complete();
}
Maza
  • 76
  • 4
  • Does this answer your question? [Transactionscope throwing exception this platform does not support distributed transactions while opening connection object](https://stackoverflow.com/questions/56328832/transactionscope-throwing-exception-this-platform-does-not-support-distributed-t) – Alexandra Petrova Mar 31 '20 at 16:12
  • 2
    Thanks! Not really, I have already seen it and this answers does not solve my issues. I'm using .net core 3.0 and as I mentioned it's working on Azure but not locally on my Windows comupter. Microsoft says on their page thats working for it with an example. Can somebody specify why its working on Azure but not locally and will there be a solution for it? Thanks a lot for you help! – Maza Apr 01 '20 at 06:35

0 Answers0