What Exception is thrown by Entity Framework Core 6.0 when a transaction fails - entity-framework-core

According to the documentation for Entity Framework Core 6.0, transactions are automatic and an exception is thrown when a transaction fails. I'd like to add some retry logic when this happens but I can't find any documentation about which exception is thrown. Can anyone tell me?

Related

Axon: Expecting constraint violation for existing #Aggregate using EmbeddedEventStore

As a follow-up to Axon Event Published Multiple Times Over Eventbus, when using an EmbeddedEventStore and publishing a command that will attempt to create an instance of an aggregate that already exists, Axon is not throwing an exception indicating the instance exists (or constraint violation), as is on the contrary, when using Axon's JPA event store. Is this the expected behavior? If so, why?
Recently our community filed a similar issue to our repo that I am going refer here.
Essentially the JPA or JDBC implementation are responsible for catching this kind of exceptions and translating them to something the Framework understands.
If that occurs, you should see an AggregateStreamCreationException dispatched, indicating that it failed and why it failed. If this is not happening I recommend you looking into your PersistenceExceptionResolver.
If you still see this happening after checking what I shared, this is likely a bug and in this case, feel free to open it on our repo as such.

Tomcat is shutdown when the out of memory

We are using a JPA for the entity manager and when the multiple users access the reports at the same time it throwing an exception and getting out of memory exception. Am checked the is there any possibilties to the memory leakage and i have a doubt that we are not clear the entity when we get the data from the database. Please any one help me out for this. Thanks in advance

Crash on CreateConnection SQL CE

Hi we have a product of a C# WPF application riding upon a C++ engine.
Occasionally (more often than we would like) we have to debug the whole stack.
Recently I started having a crash occur in the application on the creation of a connection.
connection = Database.DefaultConnectionFactory.CreateConnection(connectionString);
yes I have tried creating a connection by this method. But it produces the same error.
var factory = DbProviderFactories.GetFactory(providerName);
connection = factory.CreateConnection();
connection.ConnectionString = connectionString;
We have a SQL CE database for storing...well data.
We access it using EF Code First.
We found in the past we could improve performance by creating ONE connection (it is one file) and reusing the connection.
The app is crashing on me WHEN it creates the connection NOT our code.
I have tried catching Exception or ExecutionEnginException (I could not find FatalExecutionEngineException)
I have also tried reinstalling the various packages related to our EF stack.
All to no avail.
Please help if you have run into this problem or a MS engineer that scours the stackoverflow boards.
Managed Debugging Assistant 'FatalExecutionEngineError' has detected a problem in > >'(our application)'.
Additional Information: The runtime has encountered a fatal error. The address of the error was at 0xd8ed0f68, on thread 0x2330. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.
If there is a handler for this exception, the program may be safely continued.

DbContext.SaveChanges() without any auto transaction handling

Is there a way to execute the DbContext.SaveChanges() without invoke its internal auto transaction handling?
I'm working to handle the transaction (DbTransaction) myself, but when I invoking it's Commit, I getting error "SqlConnection does not support parallel transactions"
I believe this is due to SaveChanges is doing its own internal transaction work, which I want to suppress it.
.NET 4.5, EntityFramework.dll ver 5.
googling shows few approaches, but the code are not compatible.
Some showing SaveChanges can accept a Boolean, which it is not in this ver. and then invoking AcceptAllChanges() which method also not exist.
While some is using System.Transaction.TransactionScope, but its different with this System.Data.Common.DbTransaction.
after many PITA efforts digging over the EF thing. the only way I found out to have proper transaction control over it is best to use ObjectContext, instead of DbContext.
http://sqlanywhere-forum.sap.com/questions/11320/entity-framework-savechanges-closes-connection
this hinted the ObjectContext
DbContext codebase is genereated if your EDMX code generation strategy is set to None.
link: Is ObjectContext deprecated in .NET 4.5?
by changing it to Default, you will get ObjectContext code base gen.
the diff of them so far of what I found out, using DbContext, whenever you invoke its SaveChanges(), it will AUTO close the underneath connection, and your next db task will have a new connection, which basically break the transaction control of what I seek.
you need to run the whole db tasks without the conx being close or recreate within the transaction.
by using ObjectContext, SaveChanges() will not auto close the connection if I setup the transaction and connection codes properly before it.

Detecting errors in Core Data lightweight migration

I am using lightweight migration to update my model for the first time. Testing updates from previous version seems fine, but I would like to be able to trap failures and log them.
How and where can I intercept any migration errors before the app crashes?
Ben,
Lightweight migration occurs when the store is connected to the coordinator using the -addPersistentStoreWithType:configuration:URL:options:error: method. You can catch your errors here.
Andrew