asp net code for data in dropdownlist datasource code example

Example 1: how to update modal class using dbfirst in asp.net core

Additional Tip
If you are going to update the models from time to time, here's a convenient way to simplify the process.

Head over to menu Tools > External Tools, and then Add a new menu and fill in the following entries:

Title:

Update DbContext
Command:

dotnet.exe
Arguments:

ef dbcontext scaffold "your-connection-string" Microsoft.EntityFrameworkCore.SqlServer --output-dir=Models --force
Initial directory:

$(ProjectDir)
Then optionally tick "Use Output window", hit Apply and OK.

When you go to Tools again, this new menu should be there and ready for reuse, in just a click of a button!

Example 2: class selector to property in asp net core dropdown

<select data-val="true" data-val-required="The Employee field is required." id="Employee" name="Employee">    <option value=""></option>    <optgroup label="IT">        <option value="1">Mike</option>    </optgroup>    <optgroup label="Sales">        <option value="2">Pete</option>        <option value="4">Dean</option>    </optgroup>    <optgroup label="Admin">        <option value="3">Katy</option>    </optgroup></select>

Example 3: how to update modal class using dbfirst in asp.net core

Title:  Update DbContext
Command: dotnet.exe
Arguments: ef dbcontext scaffold "your-connection-string" Microsoft.EntityFrameworkCore.SqlServer --output-dir=Models --force
Initial directory: $(ProjectDir)

  Then optionally tick "Use Output window", hit Apply and OK.

  When you go to Tools again, this new menu should be there and ready for reuse, 
  in just a click of a button!