1

I'm new to developing Dot Net projects and I've spent most of my time developing small projects with React, Next.js, and Vue.js alongside Supabase for the database.

In the ConfigureServices method, I see tutorials use options => options.UseSqlServer:

public void ConfigureServices(IServiceCollection services)
{
    services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
    services.AddControllersWithViews().AddRazorRuntimeCompilation();
}

What is the proper way to do the same thing but with Supabase?

I downloaded the nuget package https://www.nuget.org/packages/supabase-csharp/

but I don't see any documentation on how to use this in the ConfigureServices method.

Thank you all for your advice!

1
  • By using the correct EF Core provider. Does it even have one? The package you linked to is used instead of EF Core. If you used PostgreSQL you could use the NpgSQL EF Core provider. Since Supabase is actually a hosted service though, you can't use that. Commented Oct 1, 2021 at 14:54

2 Answers 2

2

This is the documentation for supabase and I don't think this can be configured in configure services. Because you are using dbContext which is related to Entity framework if there is a package for entity framework which have support for it than you can do the following.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for looking into this. I was finally able to connect to Supabase. I had to remind myself what kind of DB Supabase is - it's a PostgreSQL. I just downloaded the NpgSql nuget package and followed along the steps listed here - npgsql.org/efcore/index.html The end result was this - ``` public void ConfigureServices(IServiceCollection services) { // Other DI initializations services.AddDbContext<BloggingContext>(options => options.UseNpgsql(Configuration.GetConnectionString("BloggingContext"))); } ```
No problem hoped it helped.
2

you can do it with one line of code in Program.cs

builder.Services.AddDbContext<Context>(options => options.UseNpgsql(builder.Configuration.GetConnectionString("Connection")));

"Connection" that come from appsettings.json you can find yours connection in your supabase account settings and pales it in appsettings.json

supabase had postgresql database not sqlserver

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.