I'm using ASP.NET MVC3 and Entity Framework with Database first aproach. I have a table with id(key), number and description columns. I need to generate a number after item insertion. I created instead of trigger where I generate number that I need (it depends on last number that allready exists in database). The problem is: When users insert items at same time the number in both cases is the same. So for both inserted items trigger fires and inside the trigger select returns same last number of item that allready exsist.
What is the best practice to solve this kind of issue? Thanks.