Particular / NServiceBus.Persistence.Sql

Native SQL Persistence for NServiceBus
https://docs.particular.net/persistence/sql/
Other
36 stars 27 forks source link

Outbox with EntityFramework - Transaction exception #149

Closed markgould closed 7 years ago

markgould commented 7 years ago

Using code very similar to this https://docs.particular.net/samples/entity-framework/?

The only difference is I'm not using the OnSaveChanges line as that isn't there with this persistence. I'm calling SaveChangesAsync in my handler instead.

This is the exception: System.Data.Entity.Core.EntityException: An error occurred while starting a transaction on the provider connection. See the inner exception for details. ---> System.InvalidOperationException: SqlConnection does not support parallel transactions.

This works fine when not using Outbox (dtc enabled)

Is there something I should be doing differently?

StackTrace.txt

SzymonPobiega commented 7 years ago

@markgould when using the outbox you need to ensure that the DB transaction is set on the entity context. Take a look at this one: https://docs.particular.net/samples/sqltransport-sqlpersistence/#receiver-project-accessing-the-ambient-database-details-entityframework-persisting-data. It should be helpful.

markgould commented 7 years ago

That worked perfectly! I must have missed seeing that. Thanks!