最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

c# - Argument type is not assignable to parameter type problem in IdentityDbContext - Stack Overflow

matteradmin8PV0评论

I am currently using .Net Framework Identity

And been following a video tutorial.

namespace SwmmDashboard
{
    public class AppDbContext : IdentityDbContext
    {
        public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { 
        
        }

        public DbSet<Device> Devices { get; set; }
        public DbSet<Parameter> Parameters {  get; set; }
        public DbSet<DataCollection> DataCollections { get; set; }
        public DbSet<User> Users { get; set; }

    }
}

I have this code where I added IdentityDbContext which is located in a different project but in the same solution. it migrated smoothly and the database updated.

but now in a different project for UI called SwmmUI,

     public Task<IActionResult> OnPostExportAsync()
 {
     return _impAndExp.Export(_context);
 }

The _context is in red stating that Screenshot of the error

I tried reinstalling the nuget but the error is still there

I am currently using .Net Framework Identity

And been following a video tutorial.

namespace SwmmDashboard
{
    public class AppDbContext : IdentityDbContext
    {
        public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { 
        
        }

        public DbSet<Device> Devices { get; set; }
        public DbSet<Parameter> Parameters {  get; set; }
        public DbSet<DataCollection> DataCollections { get; set; }
        public DbSet<User> Users { get; set; }

    }
}

I have this code where I added IdentityDbContext which is located in a different project but in the same solution. it migrated smoothly and the database updated.

but now in a different project for UI called SwmmUI,

     public Task<IActionResult> OnPostExportAsync()
 {
     return _impAndExp.Export(_context);
 }

The _context is in red stating that Screenshot of the error

I tried reinstalling the nuget but the error is still there

Share Improve this question asked Nov 17, 2024 at 13:44 AdiAdi 173 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

What I did was just to delete the duplicated AppDbContext from the other project and consolidated it to one context in the backend project of the solution, so basically, mixing both contexts

Post a comment

comment list (0)

  1. No comments so far