I'm new to C# and I'm trying to connect to a DB preferably PostgreSQL (or do I must use MS SQL?). How do I do that in VSCode and Mac (using dnx CLI)?
How to use EF7 from VSCode in Mac?
804 views Asked by Tingan Ho At
2
There are 2 answers
3
On
Update There is an official guide to getting setup in OS X. It uses SQLite, but switching out providers shouldn't be too tough.
http://ef.readthedocs.org/en/latest/getting-started/osx.html
Original answer
If you want to use VS Code, you need to setup your project using ASP.NET 5. See this guide for doing the initial project setup.
You can use EntityFramework.SQLite
or Npgsql.EntityFramework7
on OS X. To use these, add them to your project.json
file. Both are pre-release, unstable builds and require that you use their myget.org feeds. To do this, add a Nuget.config file to your project.
This is my Nuget.config file.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
<add key="AspNextVNext" value="https://www.myget.org/F/aspnetvnext/api/v2" />
<add key="Npgsql" value="https://www.myget.org/F/npgsql-unstable/api/v2" />
</packageSources>
</configuration>
If all you are looking for is a connection string then see: PostgreSQL connections strings
For an example on how to do it in C#, see the example at: Using PostgreSQL in your C# (.NET) application
Other than that, you would need to post your code that you have tried to be able to offer any further assistance. Otherwise, this is too broad a question to help.