DB table not accessible

Asked

Viewed 19 times

1

I have an associative class (Fluxousuario) between User and Flow, where Fluxousuario contains permissions of users for Flow, to know who can access a certain flow, I must go to this associative.

Problem: when trying to do...

db.FluxoUsuario.toList();

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

Fluxousuario.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; }
    }
}

Usuario.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; }
    }
}

1 answer

2


Possibly missing map the DbSet in the context:

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

Search use names of DbSet plural to differentiate the DbSet of the class of Model:

db.FluxosUsuario.toList();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.