Error Adding Controller with views using Entity Framework in Asp.NET

Asked

Viewed 123 times

0

When trying to add the following error appears: inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

Model:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MVCEntity.Models
{
    public class Usuario
    {
        public int Id { get; set; }
        public String Login { get; set; }
        public String Senha { get; set; }
    }
}

Data file where I do DB settings:

using System.Web;
using MVCEntity.Models;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;

namespace MVCEntity.Data
{
    public class TestandoMVCContext : DbContext
    {
        public TestandoMVCContext() : base ("TestandoMVC_Desenv")
        {

        }

        public DbSet<Usuario> Usuario { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();

            base.OnModelCreating(modelBuilder);
        }
    }
}

Lines added to my Web.config:

  <connectionString>
    <add name="TestandoMVC_Desenv" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=E:\Projetos\asp\MVCEntity\MVCEntity\App_Data\TestandoMVC_DB.mdf;Integrated Security=True" providerName="System.Data.SqlClient"/>
  </connectionString>
  <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
  <system.data>
    <DbProviderFactories>
      <add name="SqlClient Data Provider"
       invariant="System.Data.SqlClient"
       description=".Net Framework Data Provider for SqlServer"
       type="System.Data.SqlClient.SqlClientFactory, System.Data,   
      Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    </DbProviderFactories>
  </system.data>

HELP!!!

1 answer

0

Good by what it all looks like! After hours researching, this was nothing more than the lack of an "s" in the tag <connectionString> who would stay <connectionStrings>

Lack of attention from me!

In my case itself, however searching in other forums and even in stackoverflow (EN) there are several other types of problems that may cause the same!

Follow the link to other types of solutions: https://stackoverflow.com/questions/23576294/application-cant-scaffold-items?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

Browser other questions tagged

You are not signed in. Login or sign up in order to post.