Fix entity framework bug