Writes the model to DB. Added test program for it.