2016-03-25 25 views
0

を変換できません。私はここに記載されているチュートリアル従うことをしようとしています: Linkが暗黙的に型「System.Collections.Generic.HashSet」

をそして私はApplicationUserクラスに以下のコード

public ApplicationUser() 
    { 
     UserUpload = new HashSet(); } public ICollection UserUpload { get; set; } 
    } 

を挿入したときIdentityModels.csの次のエラーが表示されます。

'' 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(); 
     } 
    } 
} 

答えて

0

私のラップトップはここにはありませんが、コンパイルされますか?ウルタイプと

ICollection<string> UserUploads = new HashSet<string>(); 

だけ交換文字列:このような

何かが動作するはずUはSystem.Collections.Genericを使用していますが、UserUploadsについての一般的なものは何も...ウルのコードではありません。

関連する問題