Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any plans on changing connections to use Microsoft.Data.SqlClient? #12

Open
dsmeltz opened this issue May 26, 2021 · 4 comments
Open

Any plans on changing connections to use Microsoft.Data.SqlClient? #12

dsmeltz opened this issue May 26, 2021 · 4 comments
Labels

Comments

@dsmeltz
Copy link

dsmeltz commented May 26, 2021

There are some interesting features concerning Active Directory that Microsoft.Data.SqlClient brings with it. My particular scenario is creating a connection string with the newer Authentication keyword. This is used to support Active Directory Integrated, Active Directory Password and Sql Password authentication schemes.

I'm working on a .Net 5 Core project.

@sdrapkin
Copy link
Owner

I've been watching Microsoft.Data.SqlClient (MDS) project for a while. Some concerns/questions it raises:

  • Should libraries switch from System.Data.SqlClient (SDS) to MDS? Supporting SDS only would limit some (niche) features, like the one you mentioned. Supporting MDS only commits one to MDS bugs and forgoes SDS stability built on years of work. Supporting both SDS and MDS adds complexity (maintaining, testing, releasing, supporting). Switching to an interface-based "provider" layer for SDS/MDS would cost some performance, and would also imply an implicit support for not only SDS/MDS, but also for any other implementation of the SqlClient interfaces, which would result in issues filed and expectations of support.
  • Is MDS production-ready? This is highly opinionated, but the recent MDS hotfixes continue to indicate serious problems (ex. race conditions, doomed connections). At some point MDS will be mature enough to not exibit serious bugs, but it doesn't seem to be production ready yet.
  • Many new niche features of MDS require external dependencies to test. Ex. how would I test AD-auth on my laptop against Azure service account if I don't want to run/pay for AD in Azure? Do I even need to test this, or should I just assume that these MDS features work? When someone complains that they can't get AD-auth working with TinyORM, how can I replicate the problem or run their code-sample without having to setup the same external dependency/service?

One approach is to wait for MDS to become mature enough to rebase to MDM entirely and never look back. However there are still many perfectly valid users and usecases committed to .NET 4.x which will need to be supported forever with SDS. Using MDS is not a guarantee that SDS will not appear as a dependency in some 3rd-party component. The key purpose of SqlClient is that there is only one SqlClient, which can do ex. connection-pooling. .NET cannot drop SDS namespaces, so having both SDS and MDS would fragment connection-pools. The bold move for MS would have been to merge MDS into SDS and break APIs for latest versions of .NET. However that didn't happen. Making an explicit MDS dependency is also weird when the majority of usecases are content with SDS functionality and merely want a quick "Hello World" example to run. SDS rarely changes, rarely has serious bugs, and is unlikely to break TinyORM, which cannot be said about MDS.

@dsmeltz
Copy link
Author

dsmeltz commented May 31, 2021

Is there any way that the SqlClient could be overridden by the caller? Possibly via IDbConnection? That way the caller could just use the SDS by default or use provide a client of their own choosing.

@sdrapkin
Copy link
Owner

I have a few not-very-strong arguments against IDb* changes:

  • IDb* is not granular enough to indicate Sql* compatibility - ie. any other provider will compile but likely fail at runtime.
  • There are very minute performance benefits of direct Sql* non-interface binding. While they are tiny, one of the reasons many users select TinyORM is superior performance.
  • It will lead to potential API-breaking changes for existing users, who expect Sql* in existing codebases.
  • It will cause all features to adhere to the lowest common denominator (APIs on IDb*), instead of ex. taking advantage of some APIs that are specific/unique to Sql*.

APIs are always the hardest thing to get right (not claiming I did). Especially as time goes by and platforms evolve.

@sdrapkin
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants