Now we need to add the connecting bridge between our deep context and connection string.
So we need to tell our application that, hey, you need to use this application deep context to interact
as a deep context and you'll have to use this equals server with connection string that is inside upsetting.
Start, Jason.
So all of that mapping will be done inside program tasks where we are adding services to the container.
The reason we are adding that as a service here is once we add it here, we can extract that and use
it with dependency injection throughout the application.
So we will be adding deep context as a service in our application.
Now, previously in Dark Net five, all of this was done inside startup, yes, classified, but starting
with Dot Net six, they have combined with the startup and program tasks into one single file.
So here we are, adding all the services to the container and then we are configuring the request pipeline.
So now we no longer need multiple files.
Everything is much cleaner.
So in order to add service to our container, we will save builder dock services and the service that
we want to add is deep context.
So we want to configure the DB context, which expects a class name.
So here we have to tell that rich class in that application is implementing deep context that is application
deep context.
Once you write that you would press control, start to act, the U.S. statement for AB workout data.
Then here we have to pass the options.
So we'll see options here goes to.
And it would say options, don't we have to use sequel's server inside the entity framework core namespace?
That way, we're seeing that for this deep context for database.
We want to use equal survey and insight here.
We have to give the connection string.
Now, how can we extract that connection string from upsetting star Jason?
I said before that connection string is a special block that is given by the technical team.
So that's why they have given a special method to access all the key values inside that special block.
You can do that by using built a configuration.
Don't they have given a method to get connection string that will look for a key name inside upsetting
starches on inside connection strings?
What is the key game?
We should look forward.
We should look for a key with the name of effort connection and we want its value, so we will copy
default connection and paste that in the key name when we use get connection string that will actually
retrieve the connection string and configure our context.
Now here you can see its application d be context.
We are passing the options so inside our class that we have the application DB context.
We should retrieve that options and pass that to the base class off deep context.
So here we will have constructor using the snippet.
Ctrl are tap tap.
And with this class, we will receive deep context options on application context.
We call that as options, and all we want to do is pass it on to the base class of TBE context.
Pretty simple and straightforward, like this line of code is very critical.
If you do not do that, your connection will not work.
Now, right now, it might seem that we are doing lots of magic things with setting up application,
deep context, some code in program talks and we have a craving connection string from the app settings.
But this is very basic connection that you have to do with all darknet code applications when you want
to use and configure Entity Framework Core.
So this can be treated as basic steps that you should remember and memorize.
But what we are doing inside program tasks, we are just adding items to the container so that we can
extract and use with the help of dependency injection.
As we proceed with the cause, dependency injection will make much more sense and you will see how easy
it is by adding things to dependency injection to extract when we want to use them.
So with that basic configuration, we are almost there.
Next thing we have to do is we just need to create our database.
We have all the configuration that is ready.
Let's see how we can accomplish that in the next week, you.