public ViewResult Index()
{
using (ProDevPortEntities db = new ProDevPortEntities())
{
var CurrentUserId = new Guid(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString());
var profile = db.Profiles.Single(p => p.UserId == CurrentUserId);
return View(profile);
}
}
I got the same result... Would it give that error if a profile wasn't created yet, if it were empty?
EDIT: So I created a profile manually in the database, with the UserId Guid and ran the application again... Then it really went crazy...
Exception Details: System.InvalidOperationException: The model item passed into the dictionary is of type 'System.Data.Entity.DynamicProxies.Profile_921203F234A54A585EC68B31ACE1B4EF13B725A743AC34BF24722230504CFAD8', but this dictionary requires
a model item of type 'System.Collections.Generic.IEnumerable`1[ProDevPortMVC3.Profile]'.
webwired72
Member
106 Points
59 Posts
Re: How to reference MVC 3 built-in Account UserId
Jan 23, 2012 04:41 PM|LINK
I got the same result... Would it give that error if a profile wasn't created yet, if it were empty?
EDIT: So I created a profile manually in the database, with the UserId Guid and ran the application again... Then it really went crazy...
Exception Details: System.InvalidOperationException: The model item passed into the dictionary is of type 'System.Data.Entity.DynamicProxies.Profile_921203F234A54A585EC68B31ACE1B4EF13B725A743AC34BF24722230504CFAD8', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[ProDevPortMVC3.Profile]'.