如何将 MongoDB C# 驱动程序与 UWP 应用程序一起使用?

How do I use the MongoDB C# driver with a UWP app?

所以我正在尝试为副项目构建一个小界面。我有一个私有 MongoDB 实例,我正在尝试使用 UWP 作为我的 GUI。我的目标是使用 MongoDB C# 驱动程序来提供我的应用程序和服务器之间的接口。问题是驱动程序仅与 .NET Framework 4.5.2 或 .NET standard 1.5 兼容。

我在选择要与我的 UWP 应用程序一起使用以连接两者的库类型时遇到问题。有任何想法吗?如果必须的话,我什至愿意分拆一个额外的库来处理驱动程序和我的模型的接口类。

如您所知,MongoDB.Driver targets .NET Standard 1.5. However, for now, the highest version of .NET Standard that Universal Windows Platform supports is 1.4, which means this package is not compatible with UWP apps. So we can't use MongoDB C# Driver with a UWP app now. For more info, please see .NET Standard

但好消息是.NET Standard 2.0 已经发布,UWP 也将在即将发布的版本中支持它(预计今年晚些时候出货)。参见 Announcing .NET Standard 2.0. With .NET Standard 2.0, we should be able to MongoDB C# Driver in UWP apps. And if you want to do a test now, you can join Windows Insider Program and try with Visual Studio 2017 Version 15.4 Preview

Visual Studio 2017 version 15.4 Preview brings first class support for developers targeting the Windows Fall Creators Update SDK preview. The Windows Fall Creators Update brings support for .NET Standard 2.0 to UWP development.

更多信息,请参阅Visual Studio 2017 Version 15.4 Preview and UWP & .NET Standard 2.0: A preview is now available!