How to bind DropdownList in ASP.NET Core| CRUD Application with ASP.NET Core 7.0 using EF Part-1

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi friends welcome back in today's session we are going to perform crowd operations with drop down list for that I am going to create a new project here I am going to use Visual Studio 2022 I'll create a new project here I am selecting asp.net core web application with MVC here I have to provide project name so this is my project name and in this location I am going to store my project here I am selecting.net framework so in my case 7.0 is latest one so I am selecting latest Standard Version I will create the project here inside my solution I have multiple project so this newly created project I am making here starter project right click on this set as startup project here we are going to create two different models one is category another one is product model category will be used in the drop down list right click on the models right close this is my model name here I am going to define properties related to category model ID will be primary key here I am going to create another model for product add class here I will define the properties related to product table this is going to be primary key here I am adding missing them space so in category also we have to add the namespace for data annotations this is product name price quantity and here I have to define the relation between category and products table for the delcreate another property here I am going to store category ID here I am going to add category table category ID will be foreign key for that I am going to Define as foreign key here I have to pause table name that is categories now we have created category and product database models to add the appdb context for that I will create a folder and make it as data access layer so inside data access layer I am going to create a class for FDB context here we can provide any meaningful name this will be inherited from DB context here we have to add the Entity framework code we are going to use the Entity framework core code first approach here for that we have to install the framework right click on the project manage you get packages here we have to install Entity framework core related packages here I am selecting Entity framework core I'll install it then I need design we need tools also because we are going to use the code first approach to migrate the database we need tools package also we need SQL Server we are going to use databases SQL Server so we have to install this package also here I am going to add Entity framework core package reference select the DB context here I am going to access quick actions from here I am going to generate a Constructor with options here I am going to create DB set for categories and products so this DB context will be used to communicate between our application and database server now I'll go to the app settings.json because we have to Define our connection string inside app settings.json for that I am going to open app settings.json file I'll add connection string here here I am going to Define connection string name my DB connection this is the connection stream name here we have to provide server name then we need database name then we have to define the type of authentication we are going to use the windows authentication for that I am going to make it as Integrated Security as true then we are going to use the SS for that we have to enable this flag trust server certificate as true so here I can get the server name from my DB server so this is my SQL Server I am going to connect to mySQL server so this is my server name and here we are going to define the code first approach for that I have to provide the DB name so I'll give the DB name as so this is my DB name which will be created by Entity Framework so now I will go to program.cs class so I have to add this connection string Inside by program.cs class here I am registering my connection string add DB context here we have to provide our database context name so this is my appdb context name I'll configure here to pause options here so here we have to provide the namespace it is available in data access layer use SQL Server here we have to provide connection string name which is configured in app settings.json this is my connection stream I'm going to pause it here now I can migrate my database tables to the DB server for that I am going to open the package manager console first we have to add the migration it is going to be initial in our solution we have multiple projects we have to select the default project here so you can open the drop down list from here we have to select our project this is our project again I am going to run the migration so this time build is succeeded now we have to update the database so the command is update database so DB migration is completed we can open our SQL server and we can check it I'm going to refresh the databases here so this is the DB which we created cloud with drop down list I'll open the tables so we have created two different tables one is categories another one is products table here we can see the columns ID and name four categories for products we have ID name price quantity and one foreign key category ID is available we have completed basic setup of our project next session we are going to perform crowd operations for category then we will use category inside our products that's it for today if you like this video please like And subscribe to my channel thanks for watching
Info
Channel: CodeWithGopi
Views: 2,823
Rating: undefined out of 5
Keywords: .net core, Mvc, bind and access dropdownlist value in asp.net core 6, bind data to dropdownlist, bind dropdown in asp.net core 6, code with gopi, codewithgopi, crud operation in mvc 5 using entity framework, database connectivity in dot net core application, drop down list in asp.net with database, dropdownlist in asp.net core, dropdownlist in mvc, entity framework core, how to add entity frame work in dot net core 6.0, how to update dbcontext model in asp.net core application
Id: uBGRifyirN8
Channel Id: undefined
Length: 13min 18sec (798 seconds)
Published: Mon May 29 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.