Skip to content

Cant get the basic example to work #202

Closed

Description

@Maskoe

Edit: Okay it was jsut the .net version. 10 works.

I would really love to use this, but I cant get it running somehow.
Is there a full working example somewhere?

Here is what I got

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddDbContext<Context>(x =>
{
    x.UseNpgsql("User ID=postgres; Password=postgres; Database=projTest; Server=localhost; Port=6789; Pooling=true; Include Error Detail=true;Maximum Pool Size=300");
    x.UseProjectables();
});

var app = builder.Build();

var ctx = app.Services.CreateScope().ServiceProvider.GetService<Context>();
await ctx.Database.MigrateAsync();
 // ctx.Users.Add(new User { FirstName = "111", LastName = "222" });
 // await ctx.SaveChangesAsync();

var pls = await ctx.Users
    .ToListAsync();

var comeOn = await ctx.Users
    .Select(x => x.FullName)
    .ToListAsync();

app.Run();

public class User
{
    public int Id { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    
    [Projectable] public string FullName => FirstName + LastName;
}

public class Context : DbContext
{
    public DbSet<User> Users { get; set; }
    
    public Context(DbContextOptions<Context> options)
        : base(options) { }
    
}

with these packages and dotnet 9.

        <PackageReference Include="EntityFrameworkCore.Projectables" Version="6.0.2" />
        <PackageReference Include="EntityFrameworkCore.Projectables.Abstractions" Version="6.0.2" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.4">
            <PrivateAssets>all</PrivateAssets>
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
        <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />

I am simply getting System.InvalidOperationException: Unable to resolve generated expression for .User.FullName.

I really looked at everything and usually I dont ask these kinds of basic questions, since I assume it must be me. I just really, really want this library to be real and use it.

Activity

  1. PhenX commented on Apr 22, 2026

    @PhenX
    Member

    @Maskoe did you fix your issue ?

  2. Maskoe commented on Apr 23, 2026

    @Maskoe
    Author

    Yes I did. I think the issue was dotnet9. It works in dotnet10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions