Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use against a project with EF Core and Postgres? #355

Open
AndiRudi opened this issue Apr 5, 2024 · 0 comments
Open

How to use against a project with EF Core and Postgres? #355

AndiRudi opened this issue Apr 5, 2024 · 0 comments

Comments

@AndiRudi
Copy link

AndiRudi commented Apr 5, 2024

I want to start a csharprepl against an existing asp.net core app with entity framework and postgres as the database. The idea is to play with the project and especially also query the database using the models in the project. I couldn't get it to work after quite some time and maybe someone can help.

I am starting the repl normally with csharprepl but I also tried csharprepl --framework Microsoft.AspNetCore.App which did not change anything, so maybe this is not related?!

Anyway then I am starting with the following lines

#r "./MyProject/MyProject.csproj"
#r "nuget: Microsoft.EntityFrameworkCore, 8.0.3.0"
#r "nuget: Npgsql.EntityFrameworkCore.PostgreSQL, 8.0.2"

using MyProject;
using Microsoft.EntityFrameworkCore;

var optionsBuilder = new Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<MyDbContext>();
optionsBuilder.UseNpgsql("....");

var context = new MyProject.MyDbContext(optionsBuilder.Options);

and I get the following error:

(9,1): error CS1929: 'DbContextOptionsBuilder<MyDbContext>' does not contain a definition for 'UseNpgsql', 
and the best extension method overload 'NpgsqlDbContextOptionsBuilderExtensions.UseNpgsql(DbContextOptionsBuilder, 
Action<NpgsqlDbContextOptionsBuilder>?)' requires a receiver of type 'DbContextOptionsBuilder'.

I have a clue that the wrong extension method is used, but I am stuck to figure out why... Is this a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant