Sep 08 2022 01:08 AM
Summarizing a little what I have, the app creates a sql database, if it is already created, it deletes it and recreates it.
I would like to understand the part of the code where it does this, which if I'm not mistaken is this.
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("DefaultConnection", throwIfV1Schema: false)
{
Database.SetInitializer(new IdentityDropCreateInitializer());
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
Could you help me understand this part of asp.net code?
In the end, what I would like to do is tell the program not to create the database, just insert tables and data, but the database neither creates nor deletes it.
Thank you.
Sep 08 2022 01:43 AM
Hi @apenaranda,
Thanks for posting your issue here.
However this platform is used for how-to discussions and sharing best practices for building any app with .NET.Since your issue is a technical question, welcome to post it in Microsoft Q&A forum, the support team and communities on Microsoft Q&A will help you for any technical questions.
Besides, it will be appreciated if you can share it here once you post this technical question Microsoft Q&A.
Best Regards,
Lan Huang
Sep 08 2022 02:01 AM
Sep 08 2022 06:30 AM
Hi, @apenaranda thank you for sharing such amazing info. this code is work perfectly but I have one question how do we insert the delete the database again with the same name or the same file in SQL?
Sep 08 2022 10:21 PM
Sep 14 2022 05:41 AM