DB table not accessible

1

I have an associative class (User Stream) between User and Stream, where User Stream contains user permissions to Stream, to know who can access a certain stream, I must go to this associative.

Problem: trying to do ...

db.FluxoUsuario.toList();

... VS does not recognize FluxUsuario even though I can access the data in Server Explorer.

User Stream.cs:

namespace ProjetoASPNETMVC.Models
{
    public class FluxoUsuario
    {
        [Key]
        public int fluxoUsuarioID { get; set; }
        public int FluxoID { get; set; }
        public int UsuarioID { get; set; }
        public TipoPermissao TipoPermissao { get; set; }

        public virtual Fluxo Fluxo { get; set; }
        public virtual Usuario Usuario { get; set; }
    }

    public enum TipoPermissao { Ler, LerEscrever }
}

Flow.cs:

namespace ProjetoASPNETMVC.Models
{
    public class Fluxo
    {
        [Key]
        public int FluxoID { get; set; }

        [Required(ErrorMessage = "Dê um nome a fluxo")]
        [Display(Name = "Título")]
        public String Nome { get; set; }

        [Required]
        [Display(Name = "Dono do fluxo")]
        public virtual Usuario Dono { get; set; }

        [Display(Name = "Topico")]
        public String TopicoPertencente { get; set; }

        [Required]
        [Display(Name = "Visibilidade")]
        public String Visibilidade { get; set; }

        public ICollection<FluxoUsuario> UsuariosPermitidos { get; set; }

        public virtual IList<Informacao> Informacoes { get; set; }

        public object[] UsuarioID { get; internal set; }
    }
}

User.cs:

namespace ProjetoASPNETMVC.Models
{
    public class Usuario
    {
        [Key]
        public int IDUser { get; set; }

        [RegularExpression(".+\@.+\..+", ErrorMessage = "Informe um Email válido")]
        [Required(ErrorMessage ="Preencha o email")]
        public string Email { get; set; }

        [DataType(DataType.Password)]
        [Required(ErrorMessage ="Preencha a senha")]
        [Display(Name = "Senha")]
        public string Senha { get; set; }

        [NotMapped]
        [DataType(DataType.Password)]
        [Display(Name = "Confirme a senha")]
        [Compare("Senha", ErrorMessage = "As senhas digitadas não são iguais.")]
        public string ConfirmPassword { get; set; }

        [Required(ErrorMessage ="Preencha o nome")]
        public string Nome { get; set; }

        public virtual ICollection<FluxoUsuario> FluxosPermitidos { get; set; }
    }
}
    
asked by anonymous 29.12.2015 / 13:30

1 answer

2

Possible to map DbSet to context:

public DbSet<FluxoUsuario> FluxosUsuario { get; set; }

Try to use DbSet names in the plural to differentiate the DbSet from the Model class:

db.FluxosUsuario.toList();
    
29.12.2015 / 15:48