Butterfly
Butterfly
CC#
Created by Butterfly on 12/18/2023 in #help
How the mgiration works internally?
For example, I have 5 migrations added and the sql database is updated with those 5 migrations. For some reasons, I had to roll back to the first migration by removing the four migrations. Now the question is 1. How does EF core works to which migration to roll back? My understanding is they compare with MigraitonHistory Table in the sql and check with snapshot.cs file to compare? 2. How Down methods are executed? I updated to the first migration means 4 migrations down methods are executed or not? 3. How the design.cs and snapshot.cs are used when updating the db using EF core? I think snapshot shows the current snapshot without the recent migration and design.cs has the data including the relevant migraiton file. Could you guys fill me up?
2 replies
CC#
Created by Butterfly on 12/12/2023 in #help
When should you use an action filter in a real-world scenario
I can't think of much how the action filter can be improved the process of action? Is there any cases how successfully the action filter is implemented in real cases?
2 replies
CC#
Created by Butterfly on 12/13/2022 in #help
❔ Is there any tool converting csv file to Class (seeding data)?
I am using EF to seed data and I have an excel file containing like 500 records. If that's around 100 or 200, I used to use just excel or VS code multi cursors. I need to manually add data so I can't just read a file and convert it. I would like to find a way easily convert data in csv file to an object to seed data in Entity Framework.
3 replies
CC#
Created by Butterfly on 11/26/2022 in #help
❔ Registering Angular App that's in IIS to .Net
I have an Angular app that will be hosed in the site/cc. I would like C# to handle deep linking and for other reasons so I need to register that cc virtual directory in IIS . When I use wwwroot , C# recognises the route but when I try to change site/wwwroot/cc to site/cc, it does not work. Is there any reason why wwwroot which is a default static folder is working and others not working? what Did I do wrong?
app.UseSpaStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "cc"))
});

app.MapWhen((context) =>
{
_logger.LogWarning("test", context.Request.Path);
return context.Request.Path.StartsWithSegments("/cc");
},
(ccApp) =>
{
string clientApp1Path = @"cc";

// Each map gets its own physical path for it to map the static files to.
StaticFileOptions clientApp1Dist = new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), clientApp1Path)
)
};

// Each map its own static files otherwise it will only ever serve index.html no matter the filename
ccApp.UseSpaStaticFiles(clientApp1Dist);

ccApp.UseSpa(spa =>
{

if (!env.IsDevelopment())
{
spa.Options.StartupTimeout = new TimeSpan(0, 5, 0);
spa.Options.SourcePath = "cc";
spa.Options.DefaultPageStaticFileOptions = clientApp1Dist;
spa.Options.DefaultPage = "/cc/index.html";
}
});

});
app.UseSpaStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "cc"))
});

app.MapWhen((context) =>
{
_logger.LogWarning("test", context.Request.Path);
return context.Request.Path.StartsWithSegments("/cc");
},
(ccApp) =>
{
string clientApp1Path = @"cc";

// Each map gets its own physical path for it to map the static files to.
StaticFileOptions clientApp1Dist = new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), clientApp1Path)
)
};

// Each map its own static files otherwise it will only ever serve index.html no matter the filename
ccApp.UseSpaStaticFiles(clientApp1Dist);

ccApp.UseSpa(spa =>
{

if (!env.IsDevelopment())
{
spa.Options.StartupTimeout = new TimeSpan(0, 5, 0);
spa.Options.SourcePath = "cc";
spa.Options.DefaultPageStaticFileOptions = clientApp1Dist;
spa.Options.DefaultPage = "/cc/index.html";
}
});

});
2 replies