c# - edit user profile image with usermanager -
i'm following this tutorial add profile picture once account create.
that edit has following snippet,
student student = db.students.include(s => s.files).singleordefault(s => s.id == id);
in above example applied table call student
in case want go aspnetuser
table , have go usermanger
feature , once try include
file popping error in compile time.
but in scenario i'm trying include in aspnetuser
or usermanager
so populate uploaded picture. need include
following code in user manager
var user = await usermanager.include(s => s.files).findbyidasync(userid);
but getting following error
'applicationusermanager' not contain definition 'include' , no extension method 'include' accepting first argument of type 'applicationusermanager'
how ignore , include files
edit:
these changes i've done in model classes
file
public class file { public int fileid { get; set; } .. public virtual applicationuser usermanager { get; set; } }
filepath
public class filepath { public int filepathid { get; set; } .. public virtual applicationuser usermanager { get; set; } }
applicationuser
public class applicationuser : identityuser { .... public virtual icollection<file> files { get; set; } public virtual icollection<filepath> filepaths { get; set; } public async task<claimsidentity> generateuseridentityasync(usermanager<applicationuser> manager) { .... } }
aspnetuser
public partial class aspnetuser { public aspnetuser() { .. } .... public virtual icollection<file> files { get; set; } public virtual icollection<filepath> filepaths { get; set; } }
then try add migration project typing following pmc:
add-migration file
add-migration filepaths
then getting following error in console
no migrations configuration type found in assembly 'project_name'. (in visual studio can use enable-migrations command package manager console add migrations configuration).
then typed following pmc:
enable-migrations project_name.models.sampleentityframeworkentities
then got following error in console
creating dbmodelbuilder or writing edmx dbcontext created using database first or model first not supported. edmx can obtained code first dbcontext created without using existing dbcompiledmodel.
then try migrate files
, filespath
using following code
add-migration file
add-migration filepaths
get error in console
creating dbmodelbuilder or writing edmx dbcontext created using database first or model first not supported. edmx can obtained code first dbcontext created without using existing dbcompiledmodel.
if understood correctly you're trying follow guide using asp.net identity. asp.net identity unique system own classes , dbcontext. in order add new fields user need modify applicationuser class. add property class , apply migration if needed. add new column aspnetuser. add field viewmodel (if any) , other logic required work field.
Comments
Post a Comment