How to insert into a Model as Soon as a View is created

I have an Exercise Model that has can belong to a Workout or it can be standalone:

@Model
class Exercise {
    var id: UUID
    var exerciseName: ExerciseName
    
    @Relationship(deleteRule: .cascade)
    var sets: [Set]?    //When an Exercise gets Deleted all Sets associated need to get deleted
    var date: Date
    var workout: Workout?       //it can belong to a work but it doesnt have to
    
    init(id: UUID, exerciseName: ExerciseName, date: Date) {
        self.id = id
        self.exerciseName = exerciseName
        self.date = date
    }
    
    
}

and then I have a Workout which should be initialized as soon as the user Navigates to AddWorkoutView so that it can be passed to the ExerciseView:

@Model
class Workout {
    var id: UUID
    var name: String?
    
    @Relationship(deleteRule: .cascade) //when deleting a workout you delete all exericses that happened during that workout
    var exercises: [Exercise]?
    
    var date: Date
    
    init(id: UUID, date: Date) {
        self.id = id
        self.date = date
    }
}

How do I initialize a Workout when the users navigates to this page so that I can pass said workout to the sheet?

import SwiftUI
import SwiftData

struct AddWorkoutView: View {
    
    @Environment(.modelContext) var modelContext
    @Query var exercises: [Exercise]
    @State private var workoutName: String = ""
    @State private var showExercieSheet = false
    //var workout: Workout
    
    
    var body: some View {
        
        VStack() {
            VStack(spacing: 60) {
                VStack {
                    HStack{
                        Text("Create New Workout")
                            .font(.title)
                            .fontWeight(.semibold)
                        Spacer()
                    }
                    .padding(.leading)
                    
                    TextField("Enter workout name",text: $workoutName)
                        .textFieldStyle(.roundedBorder)
                        .font(.title3)
                        .padding()
                }
                
                
                if(exercises.isEmpty) {
                    //chat why does this VStack have padding that i didnt add
                    VStack(alignment: .leading ,spacing: 10){
                        Text("Exercises")
                            .font(.headline)
                            .foregroundStyle(.gray)
                        
                        Text("Press Add Exercise to create your first exercise")
                            .foregroundStyle(.gray)
                            .font(.subheadline)
                    }
                    
                    
                }
                else
                {
                    
                    List(exercises) { exercise in
                        Text(exercise.exerciseName.name)
                    }
                    
                }
                
                
                Button {
                    showExercieSheet = true
                    
                } label: {
                    Text("Add Exercise")
                        .font(.headline)
                        .foregroundStyle(.white)
                        .frame(height: 55)
                        .frame(maxWidth: .infinity)
                        .background(Color.blue)
                        .clipShape(RoundedRectangle(cornerRadius: 16))
                        .shadow(radius: 2)
                        .padding()
                }
                
                
                Spacer()
                
                
                
                
                
            }
            .toolbar {
                Button {
                    //Save the Content
                    
                } label: {
                    Text("Save")
                        .font(.headline)
                        .underline()
                        .foregroundStyle(.blue)
                        .fontWeight(.semibold)
                        .padding()
                    
                }
            }
            .sheet(isPresented: $showExercieSheet) {
                AddExerciseView()
                    .presentationDragIndicator(.visible)
            }
            
            
        }
        
        
        
        
    }
    
    
}

this is the view that the sheet presents:

import Foundation
import SwiftUI
import SwiftData

struct AddExerciseView: View {
    @Environment(.modelContext) var modelContext
    @Query var exercisesNames: [ExerciseName]
    @State private var showNameInput = false
    @State private var exerciseName = ""
    @State private var selection: ExerciseName?
    @Environment(.dismiss) private var dismiss
  //  private var workout: Workout

    
    var body: some View {
       

        VStack {
            HStack{
                Spacer()
                Button {
                    //more to come
                    showNameInput.toggle()
                    
                } label: {
                    showNameInput ?
                    Image(systemName: "minus.circle")
                        .resizable()
                           .frame(width: 24, height: 24)
                    :
                    Image(systemName: "plus.circle")
                        .resizable()
                           .frame(width: 24, height: 24)
                    
                }
                .padding(28)
              
            }
            if(showNameInput == true) {
                HStack{
                    TextField("Enter Exercise Name", text: $exerciseName)
                        .frame(height: 35)
                        .textFieldStyle(.roundedBorder)
                        .font(.title3)
                        .padding(.leading)
                    
                    Button {
                        //database operation adding exerciseName to ExerciseName model
                        if (!exerciseName.isEmpty) {
                            let newExeriseName = ExerciseName(name: exerciseName)
                            modelContext.insert(newExeriseName)
                            showNameInput.toggle()
                        }
                        
                    }label: {
                        Text("Add")
                    }
                    .font(.headline)
                    .foregroundStyle(.white)
                    .frame(height: 35)
                    .frame(width: 70)
                    .background(Color.blue)
                    .clipShape(RoundedRectangle(cornerRadius: 8))
                    .shadow(radius: 1)
                    .padding()
                }
               
            }
         
            List(exercisesNames,id: .self, selection: $selection)  { exercisename in
                Text(exercisename.name)
            }
            
            
            Button {
                //check If selection isnt empty than create an Exercise with this(selection) as the ExerciseName
                //and dismiss this sheet
                if(selection != nil) {
                    let newExercise = Exercise(id: UUID(),exerciseName: selection!, date: Date.now)
                    modelContext.insert(newExercise)
                    print("inserted: (newExercise.exerciseName.name)")
                    dismiss()
                }
                
            } label: {
                Text("Done")
                    .font(.headline)
                    .foregroundStyle(.white)
                    .frame(height: 55)
                    .frame(maxWidth: .infinity)
                    .background(Color.blue)
                    .clipShape(RoundedRectangle(cornerRadius: 16))
                    .shadow(radius: 2)
                    .padding()
            }
            
            
        }
        .onAppear {
            if exercisesNames.isEmpty {
                showNameInput=true
            }
        }
        
        
    }
       
}

#Preview {
    AddExerciseView()
}

So far I have tried creating a Workout object and inserting it into the modelContext inside an OnAppear modifier but it was not successful.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật