c# - cs0029 cannot implicitly convert type 'ApplicationUser' to 'User' -
i creating app register , authentication. using article in there. https://azure.microsoft.com/en-gb/documentation/articles/web-sites-dotnet-deploy-aspnet-mvc-app-membership-oauth-sql-database/
i errors after creating controllers in article, before enabling migrations. of course can't enable migrations cause lots of errors. what do?
i searched answers 'string' 'int' or similar.
full error: cs0029 c# cannot implicitly convert type 'pinggod.models.applicationuser' 'pinggod.models.user'
also other error same meaning other way around: cs1503 c# argument 1: cannot convert 'pinggod.models.user' 'pinggod.models.applicationuser'
thanks in advance!
using system; using system.collections.generic; using system.data; using system.data.entity; using system.linq; using system.net; using system.web; using system.web.mvc; using pinggod.models; namespace pinggod.controllers { public class userscontroller : controller { private applicationdbcontext db = new applicationdbcontext(); // get: users public actionresult index() { return view(db.users.tolist()); } // get: users/details/5 public actionresult details(int? id) { if (id == null) { return new httpstatuscoderesult(httpstatuscode.badrequest); } users users = db.users.find(id); //here error (cs0029) if (users == null) { return httpnotfound(); } return view(users); } // get: users/create public actionresult create() { return view(); } // post: users/create [httppost] [validateantiforgerytoken] public actionresult create([bind(include = "userid,name,address,city,state,zip,email,url")] users users) { if (modelstate.isvalid) { db.users.add(users); //here error (cs1503) db.savechanges(); return redirecttoaction("index"); } return view(users); } // get: users/edit/5 public actionresult edit(int? id) { if (id == null) { return new httpstatuscoderesult(httpstatuscode.badrequest); } users users = db.users.find(id); //here error (cs0029) if (users == null) { return httpnotfound(); } return view(users); } // post: users/edit/5 [httppost] [validateantiforgerytoken] public actionresult edit([bind(include = "userid,name,address,city,state,zip,email,url")] users users) { if (modelstate.isvalid) { db.entry(users).state = entitystate.modified; db.savechanges(); return redirecttoaction("index"); } return view(users); } // get: users/delete/5 public actionresult delete(int? id) { if (id == null) { return new httpstatuscoderesult(httpstatuscode.badrequest); } users users = db.users.find(id); //here eror (cs0029) if (users == null) { return httpnotfound(); } return view(users); } // post: users/delete/5 [httppost, actionname("delete")] [validateantiforgerytoken] public actionresult deleteconfirmed(int id) { users users = db.users.find(id); // here error (cs0029) db.users.remove(users); //here other error (cs1503) db.savechanges(); return redirecttoaction("index"); } protected override void dispose(bool disposing) { if (disposing) { db.dispose(); } base.dispose(disposing); } }
both users class different, that's why got error
use
pinggod.models.users users = db.users.find(id)
maybe helps u
Comments
Post a Comment