Giter Site home page Giter Site logo

ims-blazor-net6's Introduction

IMS

Añadir Entity Framework Core

Instalar los siguiente paquetes NuGet:

  • Microsoft.EntityFrameworkCore.Design, v7.x.x
  • Microsoft.EntityFrameworkCore.SqlServer, v7.x.x
  • Microsoft.EntityFrameworkCore.Tools, v7.x.x

En los siguientes proyectos:

  • IMS.Plugins.EFCoreSqlServer
  • IMS.WebApp

Añadir Identity

Trabajamos sobre el proyecto IMS.WebApp, a los paquetes ya existentes,

  • Microsoft.EntityFrameworkCore.Design, v7.x.x
  • Microsoft.EntityFrameworkCore.SqlServer, v7.x.x
  • Microsoft.EntityFrameworkCore.Tools, v7.x.x

Le añadimos los siguientes:

  • Microsoft.AspNetCore.Identity.EntityFrameworkCore, v6.x.x
  • Microsoft.AspNetCore.Identity.UI, v6.x.x

Al tratarse de un proyecto en .NET 6, instalaremos la version 6.x.x

Program.cs

    //Configure EF Core for Identity
    builder.Services.AddDbContext<AccountDbContext>(options =>
    {
        options.UseSqlServer(constr);
    });

    //Configure Identity
    builder.Services.AddDefaultIdentity<IdentityUser>(options =>
    {
        options.SignIn.RequireConfirmedEmail = true;
    }).AddEntityFrameworkStores<AccountDbContext>();

    app.UseAuthentication();
    app.UseAuthorization();

App.razor

Añadir CascadingAuthenticationState al fichero App.razor

    <CascadingAuthenticationState>
        <Router AppAssembly="@typeof(App).Assembly" >
            <Found Context="routeData">
                <RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
                <FocusOnNavigate RouteData="@routeData" Selector="h1" />
            </Found>
            <NotFound>
                <PageTitle>Not found</PageTitle>
                <LayoutView Layout="@typeof(MainLayout)">
                    <p role="alert">Sorry, there's nothing at this address.</p>
                </LayoutView>
            </NotFound>
        </Router>
    </CascadingAuthenticationState>
</code>


Ejecutar migraciones

    Add-Migration -Context AccountDbContext Init-Identity
    Update-Database -Context AccountDbContext Init-Identity

Identity Scaffolding

  • Add > New Scaffolded Item > Identity
  • Check Login and Register page.

ims-blazor-net6's People

Contributors

jmmoyadev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.