C
C#2y ago
PatrickG

❔ how to use EF6 in library with no dependancy injection and no startup.cs

I used EF core power tools to generate DB Context and reverse engineer the models. now I get an error: System.InvalidOperationException HResult=0x80131509 Message=No database provider has been configured for this DbContext. A provider can be configured by overriding the 'DbContext.OnConfiguring' method or by using 'AddDbContext' on the application service provider. If 'AddDbContext' is used, then also ensure that your DbContext type accepts a DbContextOptions<TContext> object in its constructor and passes it to the base constructor for DbContext. Source=Microsoft.EntityFrameworkCore
all the answers I can find are doing something in startup.cs which i dont have or using the dependancy injection framework which i dont use either
2 Replies
PatrickG
PatrickGOP2y ago
holy shit i actually figured it out I added this to my context protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer("myconnstring"); }
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server