Create Context class optional constructor in fly Go to Visual Studio 2022 and Right click on the project Add->Class give a Name as ContactDbContext Inherit it from DbContext Then right click on the class name Proess Ctrl + (.)Period Symbol select Generate Constructor 'ContactDbContext(options)' Format:Contrctuctor 'ClassName(options)' then it will create a optional constructor automatically you can press ctor snippet to auto generate primary constructor here is the video link https://www.youtube.com/watch?v=zUDN5MzQuj8