updated datetime to datetime2
fixed various key declarations

also added templates tables