Handle concurrency on sql server for a booking system
However, the performance of this solution is a big concern, and I read that the order of sql commands is not guaranteed, which means if two sqls hit the server with a microsecond of difference, there is no guarantee the first will have precedence. 


I don't quite understand how the order of sql commands will affect performance per this sentence.


  Now, what happens is that when more than one user selects the same available hour, I need to be able to guarantee 100% that only the first will be able to schedule an appointment, and the other will be faced with an error.


Well first is relative, I mean really nobody will know if in a nano second if B hit his after A in regards to your previous SQL.  99.999% of the time it won't happen and if it does happen... well someone is going to get kicked, it really doesn't matter who.


  I could not come up with a mechanism that ensures no racing condition will occur.


Here is one way (fairly simple and easy):

Let say you have a table (Appointment) like:

(Int/Guid) (DateTime2)      (DateTime2)      (int/guid/varchar)
ID         AptDatTime      ReservedOn      ReservedBy
-----------------------------------------------------
1          1/1/2016 08:00 


The SQL for someone who starts the reservation would be:
(mixing C# and TSQL for brevity)

Update 
  Appointment
Set 
  ReservedOn = DateAdd('mi', 5, getdate()),
  ReservedBy = &lt;whateverUserSomething&gt;
Where 
  (ReservedOn is Null or ReservedOn &gt; DateAdd('mi', 5, getdate())


(There isn't a way that I am aware of to pull this off with entity-framework natively, you'll have to run the command manually through EF)

Then when the user accepts you do another update

Update 
  Appointment
Set 
  ReservedOn = DateAdd('yyyy', 1000, getdate()), -- or c# DateTime.Max
Where 
  (ReservedOn is Null or ReservedOn &gt; DateAdd('mi', 5, getdate())
  AND (ReservedBy == &lt;whateverUserSomething&gt;)


Actual reservations (can be EF-afied):

Select
  (columns)
From
  Appointment
Where 
  (ReservedOn &gt; DateAdd('mi', 5, getdate())


Temporary reservations (can be EF-afied):

Select
  (columns)
From
  Appointment
Where 
  (ReservedOn &gt; getdate() 
    AND ReservedOn &lt; DateAdd('mi', 5, getdate())



  By which I mean if I hit the db with 500 queries at the same time, will it be able to handle it? 


SQL Server is extremely robust, 500 queries is very small.  Unless you're using like Compact DB or Local DB maybe or a server with extremely limited cpu/memory/low IO it shouldn't be a problem.