c# - Error when trying to connect to the database EF and SQL Server -
i'm doing test new host, , facing problem connection database.
i have same project going on hosting , running on sql server 2005.
but new hosting, sql server 2012 , when trying page fetches data database returns error:
a network-related or instance-specific error occurred while establishing connection sql server. server not found or not accessible. verify instance name correct , sql server configured 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"); } }
seem need change name erpcontext
conexaoerp
in web.config
Comments
Post a Comment