database operation now writing datacontext template correctly