No, it's not necessary to cook the onions first. The baking time is long enough to ensure the onions cook perfectly in the casserole.