Reputation: 794
I'm trying to do some prototyping in a newly created Blazor web assembly application.
However when I try connection to SQL Server using Microsoft.Data.SqlClient.SqlClientFactory.Instance
, this always returns null. I must have missed something here.
I'm not using EF, just basic ADO.NET.
Any help would be greatly appreciated.
Upvotes: 0
Views: 597
Reputation: 89071
If you explicitly create a SqlConnection you'll get the error:
System.PlatformNotSupportedException: Microsoft.Data.SqlClient is not supported on this platform.
Because
Blazor WASM application will successfully compile, while referencing any .NET Standard libraries. However, you may receive some errors during runtime due to the restrictions of the browser security sandbox the app is running in. For example, browsers do not allow making arbitrary network connections, interacting directly with the file system or running native code. If a library you're using tries to do any of these things, the app will fail with System.PlatformNotSupportedException error.
Common Problems and Solutions in Blazor
Upvotes: 1