Reputation: 123
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
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
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
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:
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