How do I update the default database in ASP.NET 2013? - asp.net

So I created a website in ASP.NET 2013 and went through the login so the sample db would be created. Then I added some tables. Now I wanted to customize the AspNetUsers table with my own properties that I add to the ApplicationUser class. However when I add properties to the class and try to run the Update-Database command in the PackageManagerConsole, it fails with a "The parameter is incorrect" message. I thought this would be the way to go as I believe this is considered CodeFirst. This is an ASP.NET 4.5 VB Web Forms App.

Related

Data context Class Missing in Identity

So I have a ASP Core 3.1 project and have managed to scaffold out via EF all the rest of my existing tables from my SQL server.
These all work fine and do as i need them to.
However when i go to add Identity to the project using my existing ASP User tables i cannot find the Data context class in the Scaffold menu.
I have already tried re-loading Identity, changing the base, and changing the startup file to look at the current database connection
Any help would be appreciated
I had the same problem. I was inheriting the superclass DbContext in my ApplicationDbContext. Since I was using Identity platform, changed it to IdentityDbContext. It fixed my issue.

Asp.Net MVC core Identity Framwork 6.0 customizing table column is not reflecting in User class

I am developing a Asp.Net MVC application using framework 6.0 with Core Identity Razer pages in code first approach. I modified the AspNetUsers Table with my own table definition and successfully migrated into database. Also I have customized the AspNetUser column in DBContext.cs, But still Its throwing Invalid column error after CreateAsync operation executed. Am I doing something wrong or missing anything? Why the customization is not reflecting in CreateUser class?

asp.NET MVC Identity login page - Where is this pointing to?

I just started some tutorials on MVC (I'm an old .net framework programmer).
In the pre-configured ASP.NET MVC Web App setup (in Visual Studio 2019), I'm trying to find where the actual Login page is (the HTML). I assume this is pre-built into Microsoft Identity. Is there any way to change this login form?
These are scaffolded items Microsoft generated for you for using identity users. You have to follow some steps to add them to your project.
Press the right mouse button on your project.
Press Add
Add a new Scaffolded item
Select the identity options and click add.
Now you can a list of pages. You can select all the pages you want to use in your project. Select the data context dropdown value. The default value will generate an Application db context class for you and install the necessary packages.
Now you can see you have some extra files in your project/Areas/Identity/Pages folder. you will also find a folder named 'data' that implement Applicationdb context.

Use asp.net authorize in .net core

i want to know asp.net authorize function can it be used in .net core?
Or something can instead in authorize for .net core? thanks
You can use Microsoft.AspNetCore.Identity with Identity Server 4 to authorize your application.
The tutorial from MS is Here.
In short, you can change Authentication to Individual User Accounts when create new projects. Or you can scaffold Identity into an exist project
For example, you can scaffold Identity into an empty project:
From Solution Explorer, right-click on the project > Add > New Scaffolded Item.
From the left pane of the Add New Scaffolded Item dialog, select Identity > Add.
In the Add Identity dialog, select the options you want.
Select your existing layout page, or your layout file will be overwritten with incorrect markup:
~/Pages/Shared/_Layout.cshtml for Razor Pages
~/Views/Shared/_Layout.cshtml for MVC projects
Blazor Server apps created from the Blazor Server template (blazorserver) aren't configured for Razor Pages or MVC by default. Leave the layout page entry blank.
Select the + button to create a new Data context class. Accept the default value or specify a class (for example, MyApplication.Data.ApplicationDbContext).
Select Add.
Then generate Identity database schema:
Install-Package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
Add-Migration CreateIdentitySchema
Update-Database

Why CRUD razor pages in ASP.net CORE does not work out-of-box after Scaffolding with Database-first approch?

in VS 2019 i have created an web-app like this:
After that i have:
Created a database, and added it in VS2019 "SQL server explorer" (so connection is fine)
Then Scaffolded according to the command in the lasted post here: https://github.com/dotnet/efcore/issues/19986, and i get my "class/model" as a result of this.
Then I add my CRUD pages like demonstrated in this video: https://www.youtube.com/watch?v=q2u1VY28Drs
And that is ok, since the CRUD pages are created (Exists in solution explorer).
Now when i start the app, and manouver to the new CRUD pages as shown i the last video link, it does not work out of the box, the page does not exist: No webpage was found for the web address: https://localhost:44335/V2/index. I dont understand why, but suspect it has something to do with routing.
Or, what could be the problem here?
tnx
Updated 19.10
I create a MCV app, and follow the steps 1&2 above, then i follwo this guide at the "Add model" step: **https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/?view=aspnetcore-3.1 ** and
then add this: using Microsoft.EntityFrameworkCore; in my startup file. I do not add using MvcMovie.Data;
And it still do not work, the documentation is lacking to be mild on the database first approach. What do i NEED to do from the step: "Add a Model" in the MVC guide? anyone?
Or, what could be the problem here?
The key of this issue is that the project in this video is in asp.net core razor page rather than asp.net core mvc.
When you create the project, in Create a new ASP.NET Core web application box ,you should choose the template of Web Application, you can have a look for official documents:
Then you can follow the video operation to create the crud pages.
If it is in the asp.net core mvc project, you need to create New scaffolded Item in the Controller folder and should select MVC Controller with views, using Entity Framework template, you can have a look for this.

Resources