Refactored exercise code and added Entity framework