0

I'm doing test with a new host, and I am facing a problem with the connection to the database.

I already have the same project going on another hosting and running on SQL Server 2005.

But this new hosting, SQL Server is 2012 and when trying to get a page that fetches data from the database returns this error:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

Connection string:

<connectionStrings> <add name="ERPContext" connectionString="Data Source=SQL5003; Initial Catalog=DB_99C4E9;User Id=DB_99C4E9;Password=senha;" providerName="System.Data.SqlClient" /> </connectionStrings> 

ERPContext:

 public class ERPContextUser : DbContext { public DbSet<UsuarioAtivacao> UsuarioAtivacao { get; set; } public ERPContextUser() : base("ConexaoERP") { Database.SetInitializer<ERPContextUser>(null); } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<UsuarioAtivacao>().ToTable("Usuario"); } } public class ERPContext : DbContext { public DbSet<Empresa> Empresa { get; set; } public DbSet<Pessoa> Pessoa { get; set; } public DbSet<Usuario> Usuario { get; set; } public DbSet<UsuarioAcesso> UsuarioAcesso { get; set; } public DbSet<SimNao> SimNao { get; set; } public DbSet<Sexo> Sexo { get; set; } public DbSet<TipoPessoa> TipoPessoa { get; set; } public DbSet<UnidadeMedida> UnidadeMedida { get; set; } public ERPContext() : base("ConexaoERP") { Database.SetInitializer<ERPContext>(null); } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<Empresa>().ToTable("Empresa"); modelBuilder.Entity<Pessoa>().ToTable("Pessoa"); modelBuilder.Entity<Usuario>().ToTable("Usuario"); modelBuilder.Entity<UsuarioAcesso>().ToTable("UsuarioAcesso"); } } 
1
  • Have you checked that the server SQL5003 (or a suitable alias) exists, that SQL is installed as a default instance on that server, and that SQL is configured to allow remote connections? Commented May 2, 2013 at 16:43

1 Answer 1

1

seem you need to change the name ERPContext to ConexaoERP in your web.config

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.