سؤال

Let's say I have a database with a table called "invoices".

Then I have a web application where users can manually create invoices against said table. I also have a desktop application that can create invoices programatically. I may have other software modules that can all create invoices.

To manage the operations against the database I'm using an ORM framework (Entity Framework specifically). I want to do this for all the modules.

But, if each module has its own DbContext, the problem I face is that when two modules want to create invoices at the same time, the IDs of the new records will be the same, and then one of the CREATE operations will fail.

To prevent this, my approach is to develop a web API that will act as the only entry point to write new data to the database. The only DbContext I will use for writing data will live inside this API, so colliding IDs will not happen.

Is this solution right? Does this have any possible drawbacks?

هل كانت مفيدة؟

المحلول

Options I see:

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى softwareengineering.stackexchange
scroll top