简体   繁体   English

如何在没有实体框架的情况下获取 .net 核心到 Azure SQL 的连接字符串?

[英]how to get connection string in .net core to Azure SQL without Entity Framework?

I am currently created one Aspnet core C# web api search, which need connected to Azure SQL server. I am currently created one Aspnet core C# web api search, which need connected to Azure SQL server.

Anyone know what is the connection String I need to use?任何人都知道我需要使用的连接字符串是什么?

We have some existing stored procedures, and want to call it directly without using Entity Framework Core.我们有一些现有的存储过程,并希望不使用 Entity Framework Core 直接调用它。

Here is my Azure Data Studio login information.这是我的 Azure Data Studio 登录信息。

在此处输入图像描述

Here is the code I am using to get connect to Azure SQL这是我用来连接到 Azure SQL 的代码

string connectionString = "Server=testServer.database.windows.net;Database=testDB; Authentication=Active Directory Integrated;";
                using (SqlConnection sqlConnection = new SqlConnection(connectionString))
                {
                        try
                        {
                            sqlConnection.Open();

                        }catch(Exception ex)
                        {
                        }
                }

Thanks谢谢

After a couple of hours testing and I found one connection string which is working for me.经过几个小时的测试,我发现了一个对我有用的连接字符串。

                string connectionString = "Data Source=server.database.windows.net;Initial Catalog=dbname;User ID=abc@def.com;Password='testing password'; Authentication='Active Directory Password'";

Hope this one can help other people who use Azure Active Directory - Universal MFA Support希望这个可以帮助其他使用Azure Active Directory 的人 - Universal MFA Support

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 .NET Framework 和 Entity Framework Core:如何获取连接字符串 - .NET Framework and Entity Framework Core: How can I get hold of the connection string .NET core - 将连接字符串读入 Entity Framework Core - .NET core - read connection string into Entity Framework Core 使用没有实体框架的 .NET 核心中的访问令牌连接到 Azure SQL 数据库 - Connect to Azure SQL Database using access token in .NET Core without Entity Framework ASP.NET核心实体框架空值连接字符串 - ASP.NET core Entity Framework null value connection string Linux Entity Framework Core上的SQL Server连接字符串无效 - Invalid SQL Server Connection String on Linux Entity Framework Core 使用.net核心时,如何存储实体框架6连接字符串 - How should I store the entity framework 6 connection string when using .net core 如何从没有实体框架的.NET Core 2.1 Web API中检索类中的连接字符串 - How to retrieve connection string in class from .NET Core 2.1 Web API w/o Entity Framework 如何为 Entity Framework Core 设置本地机器的连接字符串? - How to set a connection string to a local machine for Entity Framework Core? 如何在 Entity Framework Core 中将连接字符串传递给 DBContext? - How do I pass connection string to DBContext in Entity Framework Core? 获取实体框架连接字符串 - Get the Entity Framework Connection String
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM