【发布时间】:2016-03-25 12:31:11
【问题描述】:
我正在尝试按照此处列出的教程进行操作: Link
当我插入下面的代码时
public ApplicationUser()
{
UserUpload = new HashSet(); } public ICollection UserUpload { get; set; }
}
进入 IdentityModels.cs 的 ApplicationUser 类我得到以下错误:
'不能将类型'System.Collections.Generic.HashSet'隐式转换为'System.Collections.Generic.ICollection'。存在显式转换(您是否缺少演员表?)。
我对编程很陌生,不知道该怎么做!任何帮助将不胜感激,谢谢。整个代码如下。它基于 VS 2015 中的 MVC 5 构建。
using System.Data.Entity;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using System.Collections.Generic;
namespace ENUSecretShare.Models
{
// You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more.
public class ApplicationUser : IdentityUser
{
public string FName { get; set; }
public string LName { get; set; }
public int nValue { get; set; }
public int tValue { get; set; }
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
public ApplicationUser()
{
UserUpload = new HashSet(); } public ICollection UserUpload { get; set; }
}
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("DefaultConnection", throwIfV1Schema: false)
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
}
【问题讨论】:
标签: asp.net-mvc azure hashset icollection