0
votes

I am executing a simple sql against Azure SQL server. The list returns the correct number of items but then I get these 2 errors.

List<string> makes = _context.Cars.FromSql("select distinct(make) from cars").Select( l=> l.make).ToList();

A connection was successfully established with the server, but then an error occurred during the login process. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)

An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure()' to the 'UseSqlServer' call.'

What is the issue ??

1

1 Answers

0
votes

I used only "pure linq" and it works. It seems that there is an issue when trying to query SQL azure with both "pure linq" and "linq with FromSql" within the same context. Maybe the "linq with FromSql" tries to open/close a different connection.

 List<string> makes = _context.Cars.Select(j => j.make).Distinct().ToList()