A question when creating a controller . Because trying to create it has presented the error of the attached image.
I created 3 small classes: Dependentes
, Tipobenef
, TitularPlano
and ProvaContext
[Table("dependentes")]
public class Dependentes
{
public int Id { get; set; }
[Required]
[MaxLength(100)]
public string Nome { get; set; }
//public Tipobenef Tipo { get; set; }
[Required]
[ForeignKey("TitularesPlano")]
public int IdTitularPlano { get; set; }
public virtual TitularPlano Titular { get; set; }
public virtual List<Tipobenef> Tipobenefs { get; set; }
}
public enum Tipobenef
{
Filho,
Conjugue,
Pai,
Mae
}
[Table("Titularesplano")]
public class TitularPlano
{
public int Id { get; set; }
[Required]
[MaxLength(100)]
public string Nome { get; set; }
public DateTime DataNascimento { get; set; }
[Required]
[MaxLength(11)]
public string CPF { get; set; }
[Required]
[MaxLength(8)]
public string RG { get; set; }
}
public class ProvaContext:DbContext
{
public ProvaContext():base("Prova")
{
}
public DbSet<TitularPlano> Titulares { get; set; }
public DbSet<Dependentes> Dependentes { get; set; }
}
Here is the part of WebConfig
:
<add name="Prova"
providerName="System.Data.SqlClient"
connectionString="Data Source=Localhost\DESKTOP-T8VEK67; Initial Catalog=DbProva; Integrated Security=True;"/>
I already tried all the possible names of localhost
Image 1:
Image2: