4
I have an application that has 4 layers, which are the following : Dominio, Infra, Servico, Web
in the domain I have a folder called Poco
with all my Classes/Tabelas
, in the Layer Infra
, to test the CodeFirst
I believed an object and gave Servico.Add(Obejto)
to save in the bank , but when trying to access the bank I got the following error back :
'The underlying provider failed on Open'
and within that exceptio I have another that says the following :
"Instance-specific or network error when connecting to SQL Server. The server was not found or not accessible. Check that the instance name is correct and that SQL Server is configured to allow remote connections. (Preview: Named Pipes Provider, error: 40 - Unable to open SQL connection Server)
And there’s one more :
"The network path was not found"
My string conection that is called Contexto
in Server Explorer shows how 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 kingas .
I have my own Contexto
that it 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 that folder DataBaseFactory
and UnitOfWork
(If necessary I put these too)
My Connection string with the database is correct View -> Server Explorer
and put the connection this made open, but still I still try this problem.
Make sure your IIS user has access to your BD. For testing: remove USER and PASSWORD from your Connection string and adjust the BD to accept so. If it works out this is your problem.
– Gabriel Scavassa
I will test here, but I can access the database from Sql Management Studio, but I will test it for you.
– William Cézar
´{"This Operation requires a Connection to the 'master' database. Unable to create a Connection to the 'master' database because the original database Connection has been opened and credentials have been Removed from the Connection string. Supply an unopened Connection." }
– William Cézar
Made that mistake now KKK
– William Cézar
When I remove Usario and password the connection in server explorer automatically closes
– William Cézar
Yes, you have to leave your BD without user authentication and password. Create a BD part that does not have Usu and password, and place it in the Connection string.
– Gabriel Scavassa
Got it, that Bd is staying at Appharbor, I’ll see how I make these changes there.
– William Cézar
A possible solution: http://www.codeproject.com/Tips/126919/Solution-for-The-underlying-provider-failed-on-Ope
– Gabriel Scavassa
Do not solve the post , and apparently Appharbor does not let remove password and user, since it is default .
– William Cézar
Create a separate BD... A reply above has another tip, you even tried it ?
– Gabriel Scavassa
Your Initial Catalog is correct?
– rodrigorf
Yes, I don’t really know what the problem is, I think it was a problem with the server and not with the code, now it works normally. But I don’t know what solved my problem.
– William Cézar