here is my controller
I am calling these fields from the student table, but it appears to me that it is a connection problem but I have been verifying and it does not contain any errors and the connection is supposed to be fine because I can run the tables I would like you to help me solve this problem thank you very much in advance.
[HttpGet("[action]")]
public async Task<IEnumerable<AlumnoViewModel>> Listar()
{
var alumno = await _context.Alumnos.ToListAsync();
return alumno.Select(c => new AlumnoViewModel
{
idalumno = c.idalumno,
nombre = c.nombre,
apellido = c.apellido,
callenumero = c.callenumero,
colonia = c.colonia,
ciudad = c.ciudad,
estado = c.estado,
lada = c.lada,
telefono = c.telefono,
pais = c.pais,
codigopostal = c.codigopostal,
religion = c.religion,
correo = c.correo,
sexo = c.sexo,
lugarnacimiento = c.lugarnacimiento,
nacionalidad = c.nacionalidad,
fechanacimiento = c.fechanacimiento,
estadocivil = c.estadocivil,
curp = c.curp,
tiposangre = c.tiposangre,
alergias = c.alergias,
especificarenfermedad = c.especificarenfermedad,
condicion = c.condicion,
bautizado = c.bautizado
});
}
I am making my connection from appsettings.json
"ConnectionStrings": {
"Conexion": "Server=.\\DESKTOP-KB0A8AM\\SERVERSQL;Database:dbsistema;Trusted_Connection=True;MultipleActiveResultSets=true"
this is from services the injection
services.AddControllers();
services.AddDbContext<DbContextSistema>(options =>
options.UseSqlServer(Configuration.GetConnectionString("Conexion")));
The problem is in the connection string and database mapping, correcting the string name to the service and replacing the
:
with=