Troy Crowe
Troy Crowe

Reputation: 123

Connect to SQL Server using .NET Framework 4.7.2 Web API 2.0 and without using Entity Framework

I have created a Web API built on .NET Framework 4.7.2. I want to be able to communicate with SQL Server without using Entity Framework.

Microsoft.Data.SqlClient and System.Data.SqlClient are not compatible with .NET Framework 4.7.2. I really do not want to use any ORM.

Any suggestions?

Upvotes: 0

Views: 3319

Answers (2)

Troy Crowe
Troy Crowe

Reputation: 123

I figured it out. I build a .net Standard library instead of a .net Framework library.

Upvotes: 0

Saeideh miri
Saeideh miri

Reputation: 79

You can use dapper for example:

var data = new List<DapperTest>();
        using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["Analysis"].ConnectionString))
        {
             data = db.Query<DapperTest>("select * from testTable").ToList();
        }
        return data;

Upvotes: 1

Related Questions