c# - Unable to resolve service for type ApplicationContext -


i have applicationcontext following :-

you can see deriving applicationcontext childcontext (child class) in end derives `identitydbcontext'.

public class applicationcontext : childcontext {     public applicationcontext(dbcontextoptions<childcontext> options)     : base(options)     {     }      public dbset<class> class { get; set; } }   public  class childcontext : identitydbcontext<ifsuser>, iifscontext {     public childcontext(dbcontextoptions<childcontext> options)     : base(options)     {     }      public virtual dbset<student> students { get; set; } } 

startup.cs

services.adddbcontext<applicationcontext>(options =>     options.usesqlserver(configuration.getconnectionstring("applicationdb"))); 

when try instance

var context = services.getrequiredservice<applicationcontext>(); 

i following error

unable resolve service type 'microsoft.entityframeworkcore.dbcontextoptions`1[childcontext]' while attempting activate 'applicationcontext'.

in context's constructors dont need anymore

public applicationcontext(dbcontextoptions<childcontext> options) : base(options) { } 

just do

public applicationcontext(dbcontextoptions options) : base(options) { } 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -