Register a user "admin" when running the application c # mvc

1

Good afternoon, I need some idea for a web system to automatically create a user Admin as soon as I run (open) the application.

That is, when running the application with a zeroed bank, so that I do not have to register any users before logging in, the system already automatically generates this user when it is run.

I'm using asp net MVC, in Visual Studio 2017.

    
asked by anonymous 05.06.2018 / 19:29

2 answers

1

Good afternoon, Paulo. Take a look at the FrameWork Entity Seed

link

    
05.06.2018 / 20:28
0

If you are working with Code First can use the Entity Seed. To enable it run at NuGet : Enable-Migrations

 protected override void Seed(ContosoUniversity.DAL.SchoolContext context)
    {
        //  This method will be called after migrating to the latest version.

        //  You can use the DbSet<T>.AddOrUpdate() helper extension method 
        //  to avoid creating duplicate seed data. E.g.
        //
        //    context.People.AddOrUpdate(
        //      p => p.FullName,
        //      new Person { FullName = "Andrew Peters" },
        //      new Person { FullName = "Brice Lambson" },
        //      new Person { FullName = "Rowan Miller" }
        //    );
        //
    }

Source: link

    
08.06.2018 / 22:16