Skip to content

CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite 9.7.2 (latest) cannot work with Microsoft.EntityFrameworkCore.Design 10.0.2 #1101

@suugbut

Description

@suugbut

Describe the bug

CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite (9.7.2) (the latest)
Microsoft.EntityFrameworkCore.Design (8.0.2) (ok)
Microsoft.EntityFrameworkCore.Design (10.0.2) (fail)

Image

Regression

Microsoft.EntityFrameworkCore.Design (8.0.2)

Steps to reproduce

using Projects;
var builder = DistributedApplication.CreateBuilder(args);
var sqlite = builder.AddSqlite("sqlite", "c:\\databases", "mydata.db")
    .WithSqliteWeb();
var webapi = builder.AddProject<WebApi>("webapi")
    .WithReference(sqlite)
    .WaitFor(sqlite);
builder.Build().Run();



using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
builder.AddSqliteDbContext<AppDbContext>("sqlite", configureDbContextOptions: options =>
{
    if (!builder.Environment.IsDevelopment())
        return;

    options.UseSeeding((context, _) =>
    {
        context.Add(new Todo { Description = "Clean main room" });
        context.Add(new Todo { Description = "Wash dishes" });
        context.Add(new Todo { Description = "Turn all lamps" });

        context.SaveChanges();
    });

    options.UseAsyncSeeding(async (context, _, cantok) =>
    {
        context.Add(new Todo { Description = "Clean main room" });
        context.Add(new Todo { Description = "Wash dishes" });
        context.Add(new Todo { Description = "Turn all lamps" });

        await context.SaveChangesAsync(cantok);
    });
});

var app = builder.Build();

app.MapDefaultEndpoints();
if(app.Environment.IsDevelopment())
{
    using var scope = app.Services.CreateScope();
    var context = scope.ServiceProvider.GetRequiredService<AppDbContext>();
    context.Database.EnsureDeleted();
    context.Database.Migrate();
}
app.MapGet("", async (AppDbContext context, CancellationToken cantok) =>
{
    var todos = await context.Todos.ToListAsync(cantok);

    return Results.Ok(todos);
});

app.Run();



public sealed class AppDbContext(DbContextOptions<AppDbContext> options)
    : DbContext(options)
{
    public DbSet<Todo> Todos => Set<Todo>();
}
public sealed class Todo
{
    public int Id { get; set; }
    public required string Description { get; set; }
    public bool IsDone { get; set; }
}

Expected behavior

It should work for 10.0.2 too.

Or ideally, update CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite from 9.7.2 to 13.x.x.

Screenshots

No response

IDE and version

Other

IDE version

No response

Nuget packages


Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item

Metadata

Metadata

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