Why does CodeFluent support default database connections?
The CodeFluent Runtime handles the database connection automatically, for each thread. The main advantage is not to worry about managing connections, so you can do this with a client-generated class:
Customer customer = new Customer();
customer.Name = "Joe"
customer.Save();
and you never used a connection object or connection string because they are customized and ambient. 10 years ago when the product was created, people weren't very used to the expression using
(and it didn't even exist for VB.NET). Under the hood, of course, the connection opens and never closes. This is pretty similar to what the ADO.NET pool actually does.
You do not need to use the parameter closeConnectionOnCompleteCommand
if all of the execution sequences (maximum ADO connection pool size, maximum IIS thread per processor, maximum connection to the database server, etc.) are configured sequentially.
For example, if you have 100 maximum pool connections and 10 maximum connections on SQL server, this is consistent, because at one point in time you may have more connections in the pool that SQL Server will accept and you will get exceptions from SQL -server.
Historically, this error was rare because a server like IIS prior to version 7 (or maybe Windows or .NET that changed the way it works) didn't actually "spin" threads in the pool (you could get only the same multiple threads). Now, starting with IIS 7, threads are changing all the time for some reason and therefore connections will be created automatically faster and not closed by default (one per thread by default). Thus, you will get this error more often. The first solution was to make sure each "max" is configured in sequence. The second solution was to add this setting closeConnectionOnCompleteCommand
and make life easier for everyone.
source to share