I have an application that has 4 layers, which are as follows: Dominio, Infra, Servico, Web
in the domain I have a folder named Poco
with all my Classes/Tabelas
, in Layer Infra
, to test CodeFirst
eu I created an object and gave Servico.Add(Obejto)
to save in the database, but when trying to access the database I have the following error back:
'The underlying provider failed on Open'
and within that exception I have another that says the following:
"Network-specific or instance-specific error when connecting 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
And there's one more:
"The network path was not found"
My conection string that is named Contexto
in Server Explorer shows as an open connection.
<add name="Contexto" connectionString="DataSource=494.sqlserver.sequelizer.com;
Initial Catalog=db49c6a5011d0751;
Persist Security Info=True;
User ID="*";Password="*";MultipleActiveResultSets=True" providerName="System.Data.SqlClient
The Server data has been changed for security, I am using an instance of appHarbor that is empty anyway, if you need to post the data.
I have my Contexto
which is declared as follows:
public class Contexto : DbContext, IDisposable
{
//Essas são apenas algumas das Classes/Tabelas
public DbSet<AdministradorUnidade> AdministradorUnidade { get; set; }
public DbSet<Pessoa> Pessoa { get; set; }
public DbSet<Categoria> Categoria { get; set; }
public DbSet<CategoriaEspecialidade> CategoriaEspecialidade { get; set;}
public DbSet<CategoriaTratamento> CategoriaTratamento { get; set; }
public DbSet<CategoriaVideoParceiro> CategoriaVideoParceiro { get; set;}
public DbSet<CategoriaVideoServico> CategoriaVideoServico { get; set; }
public DbSet<Cidade> Cidade { get; set; }
public virtual void Commit()
{
base.SaveChanges();
}
public new void Dispose()
{
base.Dispose();
}
}
I also have in this folder DataBaseFactory
and UnitOfWork
(If necessary I put these too)
My Connection string with the database is correct, your self is in View -> Server Explorer
and put the connection is done open, but still I still try this problem.