The underlying provider failed on Open, zmiana projektu na inny komputer

0

Cześć,
Napisałem sobie sklep internetowy w ASP.NET MVC. Użyłem Entity Framework oraz MSSQL , który otwieram z Management Studio 2014.
Pozmieniałem configi na logowanie przez sql a nie przez windowsa, gdyż wymagało to (?) by postawić na sieć LAN. Skopiowałem projekt na drugi komputer.
Stworzyłem baze danych i poprzez Entity Framework kliknalem generate Database. Włączam projekt i wywala exception:
the underlying provider failed on open, exception EntityFramework przy linijce:

var osobaZalogowana = db.UżytkownicySet.Where(x=>x.CzyZalogowany == "tak").SingleOrDefault();

Co jest powodem że na komputerze nr.1 działa, a na komp nr.2 nie działa? IIS? Entity? Visual Studio? MSSQL?

Proszę o pomoc, z góry dziękuję za każą pomoc

1

Odchodząc od tematu poczytaj o ASP.NET Identity. Robienie logowania/sprawdzanie czy zalogowany w ten sposób jest złe.

1

Nie może połączyć się z bazą danych. Sprawdź czy masz serwer, bazę danych i sprawdź ustawienia firewalla.

0

@somekind: Dziękuję za odpowiedź, więc to jest na localhost, firewall będzie blokować? usunąłem i tak nie ma zmian. Server po prostu w services -> SQLServer(SQLEXPRESS) daje na start i rusza. Bazę danych owszem mam, po utworzeniu w managementStudio, w Entity w visualu kliknalem Generate Database from model i stworzylo.

Pojawia się także inny błąd:
System.data.entity.core.entityexception occurred in EntityFramework.SqlServer.dll but was not hanled in user code Additional information: An excepton has been raised that is likely due to a transient failure. If you are conneting to a SQL Azure database consider using SqlAzureExecutionStrategy

Ten błąd był na początku, potem dałem go w try catcha i ten bląd pierwszy w pierwszym poście się ukazał.
Czy ten błąd coś zmienia? Jakie może być podłoże tego błędu?

Pozdrawiam i proszę o pomoc

0

Enity Framework z Nugetów jest zainstalowane,
brak firewall nie pomaga. Ma ktoś pomysł :( ? Co mogło być defaultowo inaczej skonfigurowane na drugim komputerze że są błędy?

1

Myślałem, że skoro piszesz o sieci LAN, to łączysz się z serwerem po sieci, a nie na localhoście. Na localhosta firewall nie ma wpływu.

Jesteś pewien, że w pliku konfiguracyjnym aplikacji masz ten sam connection string, którym łączysz się z poziomu Management Studio?

1

Na nowym komputerze server lokalny MSSQL w będzie mial najprawdopodobniej inną nazwę. Zmieniłeś tą wartość w connection stringu?

0

Projekt/Web.config, jeszcze jest drugi config w Views ale chyba chodzi o ten. W którym miejscu jest wzmianka o server lokalny MSSQL ?

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=301880
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-Marketing-20170314063029.mdf;Initial Catalog=aspnet-Marketing-20170314063029;user id=sa; password=1234" providerName="System.Data.SqlClient" />
    <add name="SklepModelContainer" connectionString="metadata=res://*/Models.SklepModel.csdl|res://*/Models.SklepModel.ssdl|res://*/Models.SklepModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;initial catalog=BazaProduktow;user id=sa; password=1234;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
    <add name="SklepModel2Container" connectionString="metadata=res://*/Models.SklepModel2.csdl|res://*/Models.SklepModel2.ssdl|res://*/Models.SklepModel2.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;initial catalog=BazaProduktow;user id=sa; password=1234;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />
    <add name="SklepModel3Container" connectionString="metadata=res://*/Models.SklepModel3.csdl|res://*/Models.SklepModel3.ssdl|res://*/Models.SklepModel3.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;initial catalog=BazaProdukty3;user id=sa; password=1234;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
    <add name="SklepModelContainer1" connectionString="metadata=res://*/Models.SklepModel.csdl|res://*/Models.SklepModel.ssdl|res://*/Models.SklepModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;initial catalog=BazaProdukty4;user id=sa; password=1234;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <authentication mode="None" />
    <compilation debug="true" targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5.2" />
    <httpModules>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
    </httpModules>
  </system.web>
  <system.webServer>
    <modules>
      <remove name="FormsAuthentication" />
      <remove name="ApplicationInsightsWebTracking" />
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
    </modules>
    <validation validateIntegratedModeConfiguration="false" />
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
  </system.codedom>
</configuration>

Dziękuję za każą pomoc

0

Dlaczego masz 5 connection stringów?
Jak się powinna nazywać baza danych?
Jak się nazywa instancja SQL? Na pewno jest to .\SQLEXPRESS?
Na pewno SQL jest zainstalowany z uwierzytelnianiem Mixed i Twoje hasło dla użytkownika sa jest prawidłowe?

0
  1. tylko SklepModelContainer1 jest używany,
  2. nazwa bazy to: BazaSklep4,
  3. tak .\SQLEXPRESS, chyba ze gdzies to mogę sprawdzić, ale takie jest domyslne i tak się łączyłem
  4. wlasnie zmieniałem w Management haslo na 1234 ale cos wrocilo do defaultowe, zmienilem potem na Integrated Security = true

Proszę o pomoc, dziękuję

1 użytkowników online, w tym zalogowanych: 0, gości: 1