0

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.

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Ah, off course. Thanks !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.