-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Support for adding Aspire SQL Server? #887
Comments
Agreed 100% |
@ardalis - I can give this one a try. I have some ideas around how this can be done. |
All yours. |
@benjaminmishra any update? |
@ardalis yes, figured out that it can be done using preprocessor directive like syntax #if (UseSqlServer)
services.AddDbContext<AppDbContext>(options => options.UseSqlServer(connectionString));
#else
services.AddDbContext<AppDbContext>(options => options.UseSqlite(connectionString));
#endif Question: How do we want to expose this as an option ? I was thinking may be we can add some flags while template creation and let the user choose the database type they want to use based on this flag? |
Yes, exactly. A flag during template creation. |
Might be also worth considering if the project should maintain the recommended approach for running migrations with Aspire https://learn.microsoft.com/en-us/dotnet/aspire/database/ef-core-migrations This approach makes use of having the migrations ran from a worker service, this way the connection string can be passed in, and the service can run to completion I believe, So, we could have this worker service migrator project be optionally created with the --aspire flag? but then seems superfluous as no all projects using aspire will require to run migrations. |
It would be helpful if the project could either document or support swapping out from using sql lite to using an aspire configured instance of SQL server.
Steps to Reproduce:
1.Add configuration for a sql server reference
2.Update reference from UseSqlLite to AddSqlServerDbContext
The text was updated successfully, but these errors were encountered: