-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
feat: Extension for umbraco connection string #15186
base: contrib
Are you sure you want to change the base?
feat: Extension for umbraco connection string #15186
Conversation
Hi there @nikcio, thank you for this contribution! 👍 While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:
Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution. If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request. Thanks, from your friendly Umbraco GitHub bot 🤖 🙂 |
This is definitely an improvement! I haven't looked at the code at all, but I had thought it would be possible to add the sqlServerOptionsAction to the new UseUmbracoDatabaseProvider method to emulate the UseSqlServer method? Something like this: services.AddUmbracoDbContext<MovieContext>((serviceProvider, options) =>
{
options.UseUmbracoDatabaseProvider(serviceProvider, x =>
{
x.MigrationsAssembly(typeof(MovieContext).Assembly.GetName().FullName);
});
}); But like I said I haven't looked at the underlying code, so if that is not possible then your method should work just fine to solve the actual issue 🙂 |
That would be nice to have but the reason why I don't think it's a great fit is because the |
Ahh ok, yep that makes sense then 🙂 |
Thank you @nikcio Your PR is a great improvement! Someone from the team will look into it soon! 🎉 |
I feel like we're going to be duplicating code here, any way you can use the existing From looking at the previous PR, noticed things going in public class PersistenceComposer : IComposer
{
public void Compose(IUmbracoBuilder umbracoBuilder)
{
var connectionString = umbracoBuilder.Config.GetUmbracoConnectionString();
}
} I haven't tried out much more than that, but could it be a good start to accomplish what is needed? |
I've re-read the whole thing now, you are calling that |
Hey @nul800sebastiaan I can see this has been laying still for a while now how do you think we should proceed? |
Prerequisites
This fixes PR comment
Description
This PR adds the
GetUmbracoConnectionString
extension on theIServiceProvider
. This makes it simple to get the connection string from the provider when using a custom DbContext. (See the PR comment).This new extension method allows for the following code snippet being transformed into a much smaller example:
Before:
After: