Error trying to make a scaffold using entity framework code first c #

0

If someone could help me with the mistakes in the photo the classes are these

public class RobotDog     {         public int Id {get; set; }         public string Name {get; set; }         public bool Armed {get; set; }         public virtual RobotProduction RobotProduction {get; set; }

}

public class RobotFactory
{
    public int ID { get; set; }
    public string Name { get; set; }
    public string Location { get; set; }

    public virtual ICollection<RobotProduction> RobotProduction { get; set; }

}

public class RobotProduction
{
    public int ID { get; set; }
    public int RobotdogId { get; set; }
    public int RobotFactoryId { get; set; }
    public DateTime ProductionDate { get; set; }

    public virtual RobotDog Robotdog { get; set; }
    public virtual RobotFactory RobotFactory { get; set; }


}
public class RobotContext : DbContext
{
    public RobotContext() : base("RobotContext")

    { }
    public DbSet RobotDogs { get; set; }
    public DbSet RobotFactorys { get; set; }
    public DbSet RobotProductions {get;set; }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Conventions.Remove();
    }

}
    
asked by Danny 30.05.2018 в 19:50
source

1 answer

1

To be able to use the ToList and Find methods over a DbSet , you have to set the entity type in your DbSet of the DbSet<NombreEntidad> form. your class RobotContext should be as follows:

public class RobotContext : DbContext
{
    public RobotContext() : base("RobotContext") 
    {
    }

    public DbSet<RobotDog> RobotDogs { get; set; }
    public DbSet<RobotFactory> RobotFactorys { get; set; }
    public DbSet<RobotProduction> RobotProductions { get; set; }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Conventions.Remove();
    }
}
    
answered by 09.11.2018 в 17:16