Click here to Skip to main content
15,846,078 members
Home / Discussions / C#
   

C#

 
QuestionExtend Intellisense Pin
101100102-Feb-22 13:28
101100102-Feb-22 13:28 
AnswerRe: Extend Intellisense Pin
Dave Kreskowiak2-Feb-22 14:16
mveDave Kreskowiak2-Feb-22 14:16 
AnswerRe: Extend Intellisense Pin
OriginalGriff2-Feb-22 22:52
mveOriginalGriff2-Feb-22 22:52 
AnswerRe: Extend Intellisense Pin
Gerry Schmitz3-Feb-22 6:48
mveGerry Schmitz3-Feb-22 6:48 
QuestionHi Pin
Dijana Deleva31-Jan-22 10:56
Dijana Deleva31-Jan-22 10:56 
AnswerRe: Hi Pin
Richard MacCutchan31-Jan-22 11:06
mveRichard MacCutchan31-Jan-22 11:06 
AnswerRe: Hi Pin
OriginalGriff31-Jan-22 12:10
mveOriginalGriff31-Jan-22 12:10 
QuestionEF Core - Auto apply migrations with different SQL user Pin
Germghost31-Jan-22 2:33
Germghost31-Jan-22 2:33 
I'm very new to .Net Core so please bear with me!

I'm working on a project that uses EF Core as a data provider. I have managed to set things up so that any outstanding migrations are applied when the applicaton starts by doing the following:

Snippet from program.cs:

builder.Services.AddDbContext<MyDbContext>
   (options => options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));

builder.Services.AddTransient<IStartupFilter, MigrationStartupFilter<MyDbContext>>();

MigrationStartUpFilter.cs:

using Microsoft.EntityFrameworkCore;

public class MigrationStartupFilter<TContext> : IStartupFilter where TContext : DbContext
{
    public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next)
    {
        return app =>
        {
            using (var scope = app.ApplicationServices.CreateScope())
            {
                foreach (var context in scope.ServiceProvider.GetServices<TContext>())
                {
                    context.Database.SetCommandTimeout(160);
                    context.Database.Migrate();
                }
            }
            next(app);
        };
    }
}

This works fine, using the connection string from appSettings.json.

However - I do not want the SQL account that is used for general data access to have DDL permissions, what I'd like to do is have a different user with the correct privileges that I use just for the migrations.

Is this possible?
AnswerRe: EF Core - Auto apply migrations with different SQL user Pin
Victor Nijegorodov31-Jan-22 2:54
Victor Nijegorodov31-Jan-22 2:54 
AnswerRe: EF Core - Auto apply migrations with different SQL user Pin
Richard Deeming31-Jan-22 2:54
mveRichard Deeming31-Jan-22 2:54 
QuestionRe: EF Core - Auto apply migrations with different SQL user Pin
Germghost31-Jan-22 3:17
Germghost31-Jan-22 3:17 
AnswerRe: EF Core - Auto apply migrations with different SQL user Pin
Germghost31-Jan-22 4:02
Germghost31-Jan-22 4:02 
QuestionFill multiple comboboxes with identical information Pin
Richard A Knox27-Jan-22 3:32
Richard A Knox27-Jan-22 3:32 
AnswerRe: Fill multiple comboboxes with identical information Pin
OriginalGriff27-Jan-22 5:01
mveOriginalGriff27-Jan-22 5:01 
AnswerRe: Fill multiple comboboxes with identical information Pin
RobertSF27-Jan-22 7:40
professionalRobertSF27-Jan-22 7:40 
AnswerRe: Fill multiple comboboxes with identical information Pin
Gerry Schmitz27-Jan-22 7:56
mveGerry Schmitz27-Jan-22 7:56 
GeneralRe: Fill multiple comboboxes with identical information Pin
RobertSF27-Jan-22 9:47
professionalRobertSF27-Jan-22 9:47 
GeneralRe: Fill multiple comboboxes with identical information Pin
Gerry Schmitz27-Jan-22 18:28
mveGerry Schmitz27-Jan-22 18:28 
GeneralRe: Fill multiple comboboxes with identical information Pin
RobertSF28-Jan-22 9:01
professionalRobertSF28-Jan-22 9:01 
GeneralRe: Fill multiple comboboxes with identical information Pin
Gerry Schmitz28-Jan-22 9:44
mveGerry Schmitz28-Jan-22 9:44 
QuestionSecuring a Named Pipe Pin
Richard Andrew x6426-Jan-22 9:34
professionalRichard Andrew x6426-Jan-22 9:34 
AnswerRe: Securing a Named Pipe Pin
Luc Pattyn26-Jan-22 13:12
sitebuilderLuc Pattyn26-Jan-22 13:12 
GeneralRe: Securing a Named Pipe Pin
Richard Andrew x6427-Jan-22 8:06
professionalRichard Andrew x6427-Jan-22 8:06 
GeneralRe: Securing a Named Pipe Pin
Luc Pattyn27-Jan-22 8:11
sitebuilderLuc Pattyn27-Jan-22 8:11 
SuggestionRe: Securing a Named Pipe Pin
Randor 27-Jan-22 23:16
professional Randor 27-Jan-22 23:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.