The Registration Form return error "ArgumentNullException: Value cannot be null." in new MVC 6 project

asp.net-core-mvc asp.net-mvc entity-framework-core

Question

I just have created a new simple MVC 6 project (with Entity Framework 7), I added the connection string to database in project.json

Then I made migration to create user tables in database.

After run application, And when go to do register new user, I receive below error after fill registration form and click on Register button:

An unhandled exception occurred while processing the request.

ArgumentNullException: Value cannot be null.
Parameter name: entityType
Microsoft.Data.Entity.Utilities.Check.NotNull[T](T value, String parameterName)

Any One can help? Any idea to know more about this error?

Popular Answer

This problem occurred because of your model class which was not declared in the ApplicationDbContext.cs

Please add the class like public DbSet<UserDetails> UserDetails { get; set; }

I added this in ApplicationDbContext.cs then error gone and save data correctly.Hope this will help you



Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why