C#

Entity framework core and enhanced testability

Posted on

Entity framework aka EF is a powerful ORM tool. After using it for many years on full Net-framework(until EF6), I came across netCore version of it. If you have started working with netCore stack, this post will help a great deal to start consuming netCore EF. NetCore is an open source, cross-platform framework which can be used to develop .net applications and run them on almost all known operating systems e.g. Linux, Windows and macOS. To use EF in a netCore application, you have to go with netCore version of it. In addition to EF6 features, netCore EF has an OOTB(out of the box) inMomory database provider which can be used to create a logical relational database in the memory and use it until the life cycle of the application. This is very powerful when it comes down to writing integration tests. In netCore application, we can register the services on startup of the application. This means, our main application(could MVC web […]

Databases

Optimistic Concurrency

Posted on

Locking pessimistically a record in database could be a solution at times but mostly is itself a problem In the multiuser environment we often have to lock some data for a single user and make sure no other user accesses and changes that data at the same time. Such situations may arise when same record (a row in a table) is accessed by more than one users to make changes because the second user may end up over writing the changes of the first user. Let’s consider the following example From an online order receiving queue, different sales person can pick an order for processing. When an order is received its status is New. A sales person reviews an order using a Review form within our app, marks its status as processing, adds some comments and Saves it. The order is assigned to that sales person. Let say an order […]