0
I am new to programming and am creating a CRUD in ASP.NET Core MVC with Entity Framework, SQL Server database, through an Internet tutorial, downloaded the blessed nugets packages, which are:
Microsoft.VisualStudio.Web.CodeGeneration.Design
Microsoft.EntityFrameworkCore.Tools
Microsoft.EntityFrameworkCore.SqlServer
After I created the controller
, I was testing to see if the data (CRUD) appeared on the site but nothing, please, someone could help me?
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace CRUDProdutosASPNETCoreMVC.Models
{
public class Produto
{
[Key]
public int Produto_id { get; set; }
public string Nome { get; set; }
public string Descricao { get; set; }
public int Quantidade { get; set; }
public decimal Preco { get; set; }
}
}
using CRUDProdutosASPNETCoreMVC.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace CRUDProdutosASPNETCoreMVC.Data
{
public class ApplicationDbContext : DbContext
{
public DbSet<Produto> Produto { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder
.UseSqlServer(@"Server=DESKTOP-DJRCE3V;Database=DBAppSample;Integrated Security=True");
}
}
}
The connection with this server "DESKTOP-DJRCE3V" is correct, can access ?
– Matheus
I believe so, because in the server name field when you open sql server, this name appears and also to confirm, I entered the sql server property and it looks like this DESKTOP-DJRCE3V as server name, now connection string name is anotherDJRCE3V Diana, tried tbm but error persists.
– Diana Moura
Hello! Seed with this information is impossible to know, only by guess and guess.
– tvdias
Ok... The image has a little more information. Add your startup.Cs to the question, pf.
– tvdias
What’s the mistake???
– novic
@Dianamoura, you generated and executed the Migrations ?
– Matheus
@Matheus this Migrations you cite is to handle model changes using Code First migrations to change the database schema instead of discarding and recreating the database? be the answer for yes, I did not create. I will try to create here.
– Diana Moura
@Matheus created the Migrations and continues with the same problem. when I click on IIS Express, opens the page, This localhost page was not found No web page was found for the web address: https://localhost:44355/Student/Privacy HTTP ERROR 404
– Diana Moura
@Dianamoura, this error happens if the page does not exist, see inside Views if there is a folder and file . cshtml page
– Harry
@Harry Exists in views the folder with template class name, and also in the views has in Shared folder has viewimporta.cshtml and also within Shared has layout.cshtml
– Diana Moura
@Harry I deleted the project that posted the code and the photo here on the site, but in this new project also when I click on Iiexpress and when I click on the student name to show student names this error appears This localhost page was not findNo web page was found for the web address: https://localhost:44355/Student/Privacy HTTP ERROR 404
– Diana Moura
@novic when running the site and clicking on the project name to look like the students' names appears this information. " This localhost page was not foundNo web page was found for the web address: https://localhost:44355/Student/Privacy HTTP ERROR 404"
– Diana Moura
@tvdias excuse the question, how do I do this?
– Diana Moura
@Harry I managed to solve the problem, I put it in the correct sql server name,and Views/Shared/_Layout.cshtml in <a class="Nav-link text-dark" Asp-area="" Asp-controller="Students" Asp-action="Index">Students</a> Students were without the S consonant at the end, I put the same folder as Students and it worked, I click there on the site in Students and it appears the information, and I tested delete,creat, and it worked fine. Thank you Harry
– Diana Moura
@tvdias I managed to solve, but thank you anyway. :)
– Diana Moura
@novic managed to solve, it was the servifor that was under a different name, then and in Views/Shared/_Layout.cshtml in <a class="Nav-link text-dark" Asp-area="" Asp-controller="Students" Asp-action="Index">Students</a> Students were without the S consonant at the end, I put the same folder as Students and it worked, I click there on the site in Students and it appears the information, and I tested delete,creat, and it worked fine, Thank you. :)
– Diana Moura