Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I'm getting an error on page 51 Update the context #83

Open
sapomuyverde opened this issue Nov 28, 2021 · 2 comments
Open

I'm getting an error on page 51 Update the context #83

sapomuyverde opened this issue Nov 28, 2021 · 2 comments

Comments

@sapomuyverde
Copy link

I am following the book, and I must say that I am an absolute beginner in everything related to the .NET platform, I am a programmer in legacy languages like xBase, VFP and so on and I feel a little frustration not being able to advance because of my inexperience in the C# language, so I am stopped right on page 51 of the book in the title "Update the context", this line:

ApplicationDbContext.cs

public class ApplicationDbContext : IdentityDbContext
{

contains red squiggles (the red squiggles are in the ApplicationUser word) and I have not been able to fix it, I appreciate any help to be able to continue with the exercise of the book.

Regards,
Javier

@guntbert
Copy link

@sapomuyverde I know that you asked long time ago - did you manage to fix it?

@thehsansaeed
Copy link

here you're trying to update the context in the ApplicationDbContext.cs file. The error you're describing seems to be related to the ApplicationUser class in the IdentityDbContext.

Ensure that you have the correct namespace imported at the top of your ApplicationDbContext.cs file. It should include the necessary references for the ApplicationUser class.

using Microsoft.AspNetCore.Identity.EntityFrameworkCore;

Check Identity Configuration: Make sure that you have the necessary setup for Identity in your project. The ApplicationDbContext should be derived from IdentityDbContext<ApplicationUser>.

public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
    // Your code here...
}

Check ApplicationUser: The ApplicationUser class should be defined in your project, possibly in a separate file. It should inherit from IdentityUser.

using Microsoft.AspNetCore.Identity;

public class ApplicationUser : IdentityUser
{
    // Additional properties and methods here...
}

After making these changes, rebuild your project to make sure that any syntax errors are resolved. You can typically do this by clicking on the "Build" or "Rebuild" option in your development environment.

If you're using Visual Studio, its IntelliSense feature should help you with autocompletion and identifying errors. Make sure you're not missing any required using statements.

If the issue persists, try cleaning and then rebuilding your project. Sometimes, cached or outdated build artifacts can cause strange issues.

Ensure that you have the latest NuGet packages installed, especially for ASP.NET Core Identity. Outdated packages can sometimes cause compatibility issues.

Double-check for any typos or syntax errors in the class names, namespaces, and other identifiers. C# is case-sensitive, so even a small typo can cause issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants