在UWP应用上将Entity Framework Core与SQL Server一起使用时出错

编程入门 行业动态 更新时间:2024-10-27 20:36:47
本文介绍了在UWP应用上将Entity Framework Core与SQL Server一起使用时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个使用Entity FrameWork Core 2.0.2和SQL Server,Sqlite和PostgreSql提供程序的数据项目(标准2.0)。

I have a data project ( standard 2.0) with Entity FrameWork Core 2.0.2 and SQL Server, Sqlite and PostgreSql providers.

我有三个以上的项目用于在Windows窗体,WPF和UWP中进行演示。

I have more three projects for presentation in Windows Forms, WPF and UWP.

当我运行Windows窗体和WPF时,Entity Framework Core适用于所有提供程序,但是当我尝试在UWP上运行SQL Server提供程序时,会抛出此错误

When I run the Windows Forms and WPF, Entity Framework Core works fine for all providers, but when I try to run the SQL Server provider on UWP, it throw this

方法 EnsureCreatedAsync :

public async Task InitDataBaseAsync(DataBaseConfig config) { using (var db = GetDataContext(config)) { // Postgresql and Sqlite do not throw exception in UWP. await db.Database.EnsureCreatedAsync(); } }

我检查了三个平台的连接字符串,连接是相同。

I checked the three platforms connection string, the connection are the same.

有人遇到过这个问题吗?

Has anyone experienced this problem?

推荐答案

我更改了连接要使用的字符串 TCP / IP

I changed the connection string to use TCP/IP

之前

Data Source=xpt/SqlServerExpress;Initial Catalog=gestao_eficaz;User ID=sa;Password=somePassword

之后

Data Source=127.0.0.1,1433;Initial Catalog=gestao_eficaz;User ID=sa;Password=somePassword

也必须启用TCP / sql服务器中的IP连接

It is also necessary to enable the TCP / IP connection in the sql server

stackoverflow/questions/2388042/connect-to-sql-server-2008-with-tcp-ip

现在有效!!!

更多推荐

在UWP应用上将Entity Framework Core与SQL Server一起使用时出错

本文发布于:2023-11-14 16:21:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1587938.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:上将   Entity   UWP   Framework   Server

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!