Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

322
Views
DropDownList en cascada en .NET Core

Estoy tratando de usar el tutorial vinculado a continuación, pero adaptándolo a mi base de datos SQL para tablas de estados, distritos y escuelas que ya tengo en su lugar. Soy nuevo en .NET Core MVC y no entiendo el error ni cómo depurarlo. Cualquier ayuda apreciada.

DropDownList en cascada en .NET Core

Error: Microsoft.Data.SqlClient.SqlException: 'Nombre de objeto no válido 'Estado'.' Esta excepción se lanzó originalmente en esta pila de llamadas: [Código externo] CascadingExample.Controllers.HomeController.Index() en HomeController.cs

 [External Code] using CascadingExample.Entities; using CascadingExample.Models; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Threading.Tasks; namespace CascadingExample.Controllers { public class HomeController : Controller { private readonly ILogger<HomeController> _logger; private readonly MyDBContent _con; public HomeController(ILogger<HomeController> logger, MyDBContent con) { _logger = logger; _con = con; } public IActionResult Index() { ViewBag.StateList = _con.State.ToList(); return View(); } public JsonResult GetDistrictByStateID(int statedID) { var data = _con.District.Where(x => x.StateID == statedID).ToList(); return Json(data); } public IActionResult Privacy() { return View(); } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); } } }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

El error significa que la tabla denominada 'Estado' no se ha creado o que la base de datos a la que hace referencia no se ha creado

Revisé el dbcontext en su tutorial y no creará la tabla "Estado".

 public class MyDBContent:DbContext { private IConfigurationRoot _config; public MyDBContent(IConfigurationRoot config, DbContextOptions options) : base(options) { _config = config; } public DbSet<Category> Category { get; set; } public DbSet<SubCategory> SubCategory { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { base.OnConfiguring(optionsBuilder); optionsBuilder.UseSqlServer(_config["ConnectionStrings:DefaultConnection"]);//connection string get by appsetting.json } }

Necesitas agregar estos códigos:

 public DbSet<State> State { get; set; }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!