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

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;

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.

Azure Cosmos DB - intermittent MongoConnectionException / IOException / SocketException

I'm using Azure Cosmos DB 4.0 with MongoDB C# Driver 2.10.4.
Most of the times the queries work fine, but I'm getting intermittent errors like this:
MongoDB.Driver.MongoConnectionException: An exception occurred while sending a message to the server.
System.IO.IOException: Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.
System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.BeginSend(...
at System.Net.Sockets.NetworkStream.BeginWrite
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.BeginWrite
at System.Net.Security._SslStream.StartWriting
at System.Net.Security._SslStream.ProcessWrite
at System.Net.Security._SslStream.BeginWrite
When that error happens the call takes 10-25 seconds before failing.
I'm building the MongoClient with new MongoClient(MongoClientSettings.FromConnectionString(cnstr)) and I was using the connectionstring with these arguments ?ssl=true&replicaSet=globaldb&retrywrites=false.
I tried with retryWrites=true (as per Azure Support suggestion) but that didn't help.
I tried different settings and that didn't work either (connect=direct, maxIdleTimeMS=30000, serverSelectionTimeout=5000ms, socketTimeout=10000ms).
What's causing those exceptions?
The fix was to set/force TLS 1.2 (based on this Microsoft document):
//return new MongoClient(connectionString);
var settings = MongoClientSettings.FromConnectionString(connectionString);
settings.SslSettings = new SslSettings()
{
EnabledSslProtocols = System.Security.Authentication.SslProtocols.Tls12
};
return new MongoClient(settings);
Looks like although my connection string had ssl=true, it wasn't enough to work on some servers (the error is intermittent). The same underlying error can usually be fixed by forcing TLS 1.2 so I assumed that in Mongo it could be the same issue - and it really fixed the problem.

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.

Azure Cosmos DB Emulator : Unable to connect to MongoDb via MongoChef

After following the instructions from the following official reference "Use the Azure Cosmos DB Emulator for local development and testing", we attempted to connect to MongoDb using MongoChef using the connection string pasted below:
mongodb://localhost:C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==#localhost:10255/admin?ssl=true
But when we test the connection through MongoChef we get the error pasted below:
Connection failed.
SERVER [localhost:10255] (Type: UNKNOWN)
|_/ Connection error (MongoSocketOpenException): Exception opening socket
|____/ Socket error: Connection refused: connect
Details:
Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27018, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused: connect}}]
If we check the ports currently in use on our system, we do not see 10255 being used at all.
Could someone please help us understand what's wrong here.
The connection string is correct. Studio 3T has a very nasty bug - when you use From URI function while creating new connection it cuts the "+" characters that are present in the key, that's why you need to copy the key manually to the corresponding field in connection properties.
Also, make sure the Emulator is actually launched (tray area icon should be present).

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

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