How to use EF7 from VSCode in Mac?

c# entity-framework-core postgresql visual-studio-code

Question

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)?

Popular Answer

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>



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why