C
C#3d ago
zaid

✅ Need help connecting to SQL Database on .NET

I have already installed the EF Core module.
30 Replies
jcotton42
jcotton423d ago
What have you tried?
zaid
zaidOP3d ago
Ive tried looking up videos online that would show me how to do it but every video im seeing has a different answer and none of the answers seem to be something that would work for me Right now I just have a database schema set up with information already in it
jcotton42
jcotton423d ago
i would not use videos for programming tutorials, they tend to be pretty poor $helloef
MODiX
MODiX3d ago
zaid
zaidOP3d ago
Ohhh i see Hey so from what im reading since i already have a database set up with all the schemas I have to reverse engineer or use scaffolding?
jcotton42
jcotton423d ago
that's called "db first," and yes that's typically what you would do in that situation
zaid
zaidOP3d ago
gotcha and one more question this is a project with a group but im the one setting up the database Is this anything like node.js where they can just clone the project and then run npm install to get all the packages or will they have to install everything as i did like the tools and then the EF core module and all that
jcotton42
jcotton423d ago
your nuget refs are in the csproj and will be restored when they open the project as for the ef tools, how did you install them?
zaid
zaidOP3d ago
Im on VSCode so what i did is dotnet add package Microsoft.EntityFrameworkCore.SqlServer in the terminal
jcotton42
jcotton423d ago
Microsoft.EntityFrameworkCore.Tools or dotnet tool install? ah, vscode and i assume you did the global install? dotnet tool install --global?
zaid
zaidOP3d ago
Hmm im not sure but i know i didnt do the global install I only did dotnet add package Microsoft.EntityFrameworkCore.SqlServer dotnet add package Microsoft.EntityFrameworkCore.Design I might be missing one
jcotton42
jcotton423d ago
those are all nuget packages, but you need dotnet ef if you're going to do reverse engineering the docs tell you to globally install that, but personally i find that to stupid, frankly
zaid
zaidOP3d ago
No description
jcotton42
jcotton423d ago
is there a .config/dotnet-tools.json in your repo?
zaid
zaidOP3d ago
Nah i cant find that
zaid
zaidOP3d ago
No description
zaid
zaidOP3d ago
This is what my file setup is looking like for the backend im following these steps rn
zaid
zaidOP3d ago
No description
zaid
zaidOP3d ago
Ive done the first 2 still havent done the 3rd prereq
jcotton42
jcotton423d ago
yeah, so you did global install, i would advise this instead
# in the same directory as your solution file
dotnet new tool-manifest # only needs to be done once
dotnet tool install dotnet-ef
# in the same directory as your solution file
dotnet new tool-manifest # only needs to be done once
dotnet tool install dotnet-ef
that will create a tool manifest and record the version of dotnet-ef you're using in it then, anyone that clones your repo can use dotnet tool restore and get the exact tools you were using
zaid
zaidOP3d ago
Ohhh i see awesome
jcotton42
jcotton423d ago
it also means that different projects on your computer can use different versions of dotnet-ef if needed, which is not possible if you install it globally i have no idea why the docs tell you to use global tools for ef, it's silly global tools don't even save space over local, regardless of how you install there's still just one copy per tool version
zaid
zaidOP3d ago
So i should just avoid using global ill stick with what u sent here in that case
zaid
zaidOP3d ago
No description
jcotton42
jcotton423d ago
for ef, yes some tools make sense to be globally installed, but dotnet-ef is not one of them
zaid
zaidOP3d ago
awesome I just need to do the 3rd prereq now So the thing is my friend has the database set up on microsoft azure or something like that but im able to connect to it from (DBeaver) using just the server name, username, and password Would i be able to connect to it similarly in .NET? Or would i need more information
jcotton42
jcotton423d ago
you would use the same connection information
zaid
zaidOP3d ago
Okk thank you so much youve been extremely helpful
jcotton42
jcotton423d ago
🙂 $close btw
MODiX
MODiX3d ago
If you have no further questions, please use /close to mark the forum thread as answered

Did you find this page helpful?