簡體   English   中英

在UWP應用程序上使用Entity Framework Core和SQL Server時出錯

[英]Error using Entity Framework Core with SQL Server on UWP app

我有一個數據項目(.net標准2.0)與Entity FrameWork Core 2.0.2和SQL Server,Sqlite和PostgreSql提供程序。

我有更多的三個項目用於在Windows窗體,WPF和UWP中進行演示。

當我運行Windows窗體和WPF時,實體框架核心適用於所有提供程序,但當我嘗試在UWP上運行SQL Server提供程序時,它會拋出此

在此輸入圖像描述

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();
   }
}

我檢查了三個平台的連接字符串,連接是一樣的。

有沒有人遇到過這個問題?

我更改了連接字符串以使用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

還必須在sql server中啟用TCP / IP連接

https://stackoverflow.com/questions/2388042/connect-to-sql-server-2008-with-tcp-ip

現在工作!!!

啟用和啟動SQL瀏覽器服務為我解決了問題。 這避免了亂搞IP地址和TCP端口。

集成安全性不起作用,但是,我不得不恢復到SQL用戶ID和密碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM