Martin Zink
Martin Zink

Reputation: 123

Windows 10 Universal app access SQL server

I am trying to create a Windows Universal app(UWP), and i need to access an SQL Server.

To my knowledge

Do i need a service layer?

Upvotes: 7

Views: 1862

Answers (3)

Bart
Bart

Reputation: 10015

Posting this reply as things have changed since the last update.

Since the Fall Creators Update (SDK 16299), UWP supports .NET Standard 2.0. This brings SqlClient to UWP and allows you to directly query SQL Server.

There was a session at Ignite on this topic (video, source) and there are several blog posts that give you a step by step guide as well to do this.

Upvotes: 0

Dan Field
Dan Field

Reputation: 21641

Yes, a service layer is required. There's an example of doing so here: How to access data from a SQL Server database in Windows 10 UWP

I wonder a bit about whether this could change given .NET Core's support for EF and ADO.NET, and the remark from this page: EF Core1 in UWP (emphasis mine):

Currently EF only supports SQLite on UWP. A detailed walkthrough on installing Entity Framework Core 1, and creating models is available at the Getting Started on Universal Windows Platform page.

My sense is that UWP's primary concern at this point is handling input, layout, and rendering in a unified way - a major challenge across the families of devices it aims to support. SQLite is pretty widely supported and safe to assume; otherwise, they seemingly went down the data contract/REST based services that are also pretty widely adopted.

Upvotes: 1

Alexej Sommer
Alexej Sommer

Reputation: 2679

Yes, you need a service layer. There is no way to connect UWP Application and SQL Server directly.

Why it's not possible:

  • UWP apps are apps that are created for distribution from Store. It's not safely to store connection string on client computer
  • You can't update all client apps in one moment if you find bug. Update service is much more easy and faster

The easiest way to create cloud service is to create Azure Mobile App and connect your UWP Application to the cloud SQL Server database with it help.

Only for MySQL databases there is possibility to connect UWP App directly to database with Connector/Net But it's not recommended way to connect mobile app and database

Upvotes: 0

Related Questions