c# - Add Strongly Typed List to Database -


i trying add entries database in controllers http post event. getting following error:

the entity type 'list' not found. ensure entity type has been added model.

code:

[httppost] [validateantiforgerytoken] public async task<iactionresult> create([bind("id,name,weight)] list<wbloading> wbloading)   {     if (modelstate.isvalid)     {         _context.entry(wbloading).state = entitystate.modified;         await _context.savechangesasync();         return redirecttoaction("index");      }      return view(wbloading); } 

i have added table dbcontext:

public dbset<models.wbloading> wbloading { get; set; } 

model:

public class wbloading {     public int id { get; set; }        public string name { get; set; }     public int weight { get; set; } } 

you need write following code.

_context.wbloading.add(wbloading);     await _context.savechangesasync(); 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -