Make sure that you have added using System.Data.Entity; namespace in your class.