C
C#6d ago
JavierWGI

Database in C#

i was following a tutorial that was using database MySql and happens that they were using SqlConnection = new SqlConnection(connectionString); from the library System.Data.SqlClient; but idk if its that im usin net9 but to my project pop up something about that class is obsolete... so they say that i should use Microsoft.Data.SqlClient and i installed. Someone know the how or why isnt available, i mean i can used it if i use an older version? Also i have the question that what its the standar to use database connection its with LINQ? or it with the Microsoft.Data.SqlClient, or something that i read about entity framework core and use it like a class,modelview,context database, sorry i am stumbling with all of these. Thanks for helping in advance. pd:was a WPF project.
9 Replies
Jimmacle
Jimmacle6d ago
those libraries are for SQL Server, not MySQL Microsoft.Data.SqlClient is the one you should be using assuming you're using SQL Server if you want to write queries with LINQ then yes you need to look at EF Core or alternatives like Linq2DB
JavierWGI
JavierWGIOP6d ago
sorry my bad, i have sql server installed i found the main error, i was creating a .net application instead a net framewokr app... LMAO
Jimmacle
Jimmacle6d ago
you should not be using .NET Framework for new projects
JavierWGI
JavierWGIOP6d ago
why ? Im new in .Net, im just following the tutorials.
Jimmacle
Jimmacle6d ago
it's an older version than the ones that are just called .NET
JavierWGI
JavierWGIOP6d ago
oh okey but there are some functionalities that i dont have in net , like setting the datasource, the reference in the solution explorer... :Hmm:
Jimmacle
Jimmacle6d ago
i can tell you that you can definitely access databases in modern .NET
JavierWGI
JavierWGIOP6d ago
yeah i know. i will know how to do the same with .net. for now i just following the tutorials.
Anton
Anton5d ago
You need Microsoft.Data not System.Data System.Data is deprecated or something

Did you find this page helpful?