Preheat the oven to 350°F.
Grease a 9 inch springform pan or a 9-inch deep dish pan.
Place a large pot of water over high heat and bring to boil. Add salt if desired.
Cook spaghetti according to package instructions, or until al dente, usually 6-9 minutes. Drain and set aside.
Add onions and garlic to a saucepan and cook over medium heat until translucent.
Add crushed tomatoes, tomato paste, oregano, basil, and salt.
Stir and simmer on low heat for 10 minutes.
Reserve 2 cups of pasta sauce and set aside.
Pour the remaining sauce into a large mixing bowl and allow to cool slightly.
Add cooked spaghetti to the bowl and stir well to generously coat the spaghetti.
Beat the eggs, then stir the egg mixture into the spaghetti.
Pour the spaghetti into the prepared pan. Using the back of a wooden spoon, press down the pasta noodles to pack the spaghetti into the pan.
Pour the ricotta cheese over on top of the spaghetti and use a spatula to spread.
Pour the remaining 2 cups of sauce over the top.
Sprinkle shredded mozzarella and Parmesan over the top.
Bake for 25 minutes or until the edges are crispy and the cheese has browned.
Let cool for at least 5-10 minutes before cutting into pie slices and serving.