Entity framework - The provider did not return a ProviderManifestToken string error - entity-framework

I am using SQL Server 2005 Express with SQL Servre authentication and remote connections enabled although I am working locally.
My web.config connection string part:
<add name="HelpDesk2connect" connectionString="metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string='Data Source=SATURN;Initial Catalog=HelpDesk2;Integrated Security=False;user id=sa;password=*******;multipleactiveresultsets=true'" providerName="System.Data.EntityClient" />
I am logging in as sa
In the controller I get these errors (in this statement: `return View(db.Tickets.ToList());)
An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct.
The provider did not return a ProviderManifestToken string.
In the page I get this error:
[SqlException (0x80131904): 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: 52 - Unable to locate a LocalDB installation. Verify that SQL Server Express is properly installed and that the LocalDB feature is enabled.)]
Can you help me spot what am I doing wrong?
Thanx in advance

Related

.NET 5 Connecting to MS Access mdb with Odbc

I am trying to connect my web application to an old MS Access mdb file.
I found this page:
https://learn.microsoft.com/en-us/dotnet/api/system.data.odbc.odbcconnection?view=dotnet-plat-ext-6.0
But I can't figure out how to work with connection strings, I keep getting the Error:
'ERROR [08001] [Microsoft][ODBC Driver 18 for SQL Server]MAX_PROVS: Error Locating Server/Instance Specified [xFFFFFFFF].
ERROR [HYT00] [Microsoft][ODBC Driver 18 for SQL Server]Login timeout expired
ERROR [01S00] [Microsoft][ODBC Driver 18 for SQL Server]Invalid connection string attribute
ERROR [08001] [Microsoft][ODBC Driver 18 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.'
https://www.connectionstrings.com/microsoft-odbc-driver-17-for-sql-server/
Found this page, although I have the 18 driver installed it should only change the 17 -> 18.
My current Connection string looks like this
Driver={ODBC Driver 18 for SQL Server}; Server=.\SQLExpress; AttachDbFilename = D:\temp\datacollector\microfas.mdb; Trusted_Connection=yes;
But I have no idea if I am approaching it the right way. The application will eventually run locally at a customer with a known location of the .mdb file.

Creating a local connection in Oracle SQL developer 12c

Not sure if I'm missing anything.
I'm trying to create a local connection in order to create a new user in Oracle SQL developer 12c. (AVOIDING CDB connection)
After browsing for an hour, came across 2 methods.
Using connection type as "Local/Bequeath"
Throws following error (Status : Failure -Test failed: ORA-01017: invalid username/password; logon denied)
Using connection type as "Basic", Hostname as "localhost", Port as "1521", and Service name as "XEPDB1"
Throws following error (Status : Failure -Test failed: Listener refused the connection with the following error:
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor)
Thanks.

quickstart error - Using EF Migrations for local SQL Server and keep loosing db connection

I am following IdentityServer4 quickstart and trying to migrate in memory data to my local SQL Server (not SQL express or LocalDB that came with VS). My connection string is:
#"Server=localhost,1434;Database=MyIDS;user id=tester_1;Password=tester_1;trusted_connection=yes;".
When I start my IdentityServer, it creates the enpty db, MyIDS, and then throw an exception with 2 inner exceptions:
Inner Exception 1:
SqlException: A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - An established connection was aborted by the software in your host machine.)
Inner Exception 2:
Win32Exception: An established connection was aborted by the software in your host machine.
Can anyone tell me what's going on here? Why a working connection always gets dropped?
localhost,1434 looks wrong, you don't need to provide the port 1434 and the commma should not be used either, it should be a colon in that case.
I typically use for local development:
server=.;Database=ASPIdentity;Trusted_Connection=True;
dot means localhost, if you use sqlexpress the connetion string would become
server=.\\sqlexpress;Database=ASPIdentity;Trusted_Connection=True;

Entity framework with db mode cannot connect to server

I am trying to connect to by db instance using db first, I created a connection
<add name="Entities"
connectionString="metadata=res://*/Models.ModelCmarket.csdl|res://*/Models.ModelCmarket.ssdl|res://*/Models.ModelCmarket.msl;provider=System.Data.SqlClient;provider connection string="data source=(localdb)\v12.0;initial catalog=Cevaheer;integrated security=True;trustservercertificate=False;multisubnetfailover=True;MultipleActiveResultSets=True;multipleactiveresultsets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
And I always get an 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: 50 - Local Database Runtime error occurred. The specified LocalDB instance does not exist.)
But if i try
<add name="CevhermarketEntities"
connectionString="Data source=(localdb)\v12.0;initial catalog=Cevaheer;integrated security=True;trustservercertificate=False;multisubnetfailover=True;MultipleActiveResultSets=True;user id=dbuser;password=flexsin#123!;multipleactiveresultsets=True;"
providerName="System.Data.SqlClient" />
I can connect, and also can connect from VS sql server explorer and SSMS.
To begin - there are 4 issues that could be causing the common LocalDb SqlExpress Sql Server connectivity errors SQL Network Interfaces, error: 50 - Local Database Runtime error occurred, before you begin you need to rename the v11 or v12 to (localdb)\mssqllocaldb
You dont have the services running
You don't have the firelwall ports here
configured
Your install has and issue/corrupt (the steps below help give you a nice clean start)
You did not rename the V11 or 12 to mssqllocaldb
I found that the simplest is to do the below - I have attached the pics and steps for help.
First verify which instance you have installed, you can do this by checking the registry and by running cmd
cmd> Sqllocaldb.exe i
cmd> Sqllocaldb.exe s "whicheverVersionYouWantFromListBefore"
if this step fails, you can delete with option d cmd> Sqllocaldb.exe d "someDb"
cmd> Sqllocaldb.exe c "createSomeNewDbIfyouWantDb" create - the pic is error
cmd> Sqllocaldb.exe start "createSomeNewDbIfyouWantDb"

Entity Framework database not working (Code First, Web Deploy)

I'm using Asp.Net MVC4 with Entity Framework Code First.
Everything works locally, but when I publish, pages without database access work (on the internet), and any page with it, loads for an age, then gives me a server error.
I have enabled migrations, I have made an InitialCreate migration that is using the current model. I have ran the "Update-Database" command without error.
Any ideas ?
EDIT, thanks to the comment below, here is some detailed information on the 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)
Error in stack trace...
[SqlException (0x80131904): 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)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5064458
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234
System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo,
SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout,
Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean
integratedSecurity) +341
Also I'm using .sdf database's. Connection strings here...
<add name="DefaultConnection" connectionString="Data Source=|DataDirectory|Data.sdf" providerName="System.Data.SqlServerCe.4.0" />
<add name="ZDataContext" connectionString="Data Source=|DataDirectory|ZData.sdf" providerName="System.Data.SqlServerCe.4.0" />
I repeat, it all works locally.
Just uploaded all files manually, got this error...
Access to the database file is not allowed. [ 1884,File name = d:\virtualservers[username]\website.co.uk\wwwroot\App_Data\ZData.sdf,SeCreateFile ]
Again that works locally, and also works on none database pages, but databases pages give me the above error.