microsoft / microsoft/aspire

Have a hosting package for Azure SQL that uses LocalDB during dev

Open
#6,251 6 comments 2 reactions 0 assignees View on GitHub
area-integrations sqlserver
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

To speed up startup (my laptop is 2 years old), instead of relying on the AddSqlServer Hosting package for SQL (which spins up a Microsoft SQL container), would a solution that uses LocalDB for local dev be interesting ?

I was able to achieve this :
```
IResourceBuilder sql = default!;
if (builder.Environment.IsDevelopment())
{
sql = builder.AddConnectionString("sql");
}
else
{
var sqlServer = builder.AddSqlServer("sql").WithHealthCheck();
var sqlData = sqlServer.AddDatabase("sqldata");
sql = sqlServer;
}

var dataMigrator = builder.AddProject("dataMigrator")
.WithReference(sql);
if (sql is IResourceBuilder) dataMigrator.WaitFor(sql);
```

At the same time, an integration package that does what the DataMigrator does (based on EF concepts)s would be awersome. Maybe seed data in a sql file in the AppHost project (seed.sql, seed.dev.sql, seed.production.sql) and somesort of mode to run the migrations (do nothing, Migrate, DropCreate, EmptyFill). I use a strategy like this that allows each EF Context to be in it's own schema.

### Describe the solution you'd like

something like :

`.addAzureSqlServerWithLocalDB("sql")`

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.