Broken it somehow and I don't fully understand this yet.
public void ConfigureServices(IServiceCollection services) { services.AddDbContext<AppDbContextFactory>(options => options.UseSqlServer(_configurationRoot.GetConnectionString("DefaultConnection"))); services.AddDbContext<AppDbContext>(options => options.UseSqlServer(_configurationRoot.GetConnectionString("DefaultConnection")));
Giving error:
he type 'BethanysPieShop.Models.AppDbContextFactory' cannot be used as type parameter 'TContext' in the generic type or method 'EntityFrameworkServiceCollectionExtensions.AddDbContext<TContext>(IServiceCollection, Action<DbContextOptionsBuilder>, ServiceLifetime)'. There is no implicit reference conversion from 'BethanysPieShop.Models.AppDbContextFactory' to 'Microsoft.EntityFrameworkCore.DbContext'
Which I find confusing when I google search it.
This is also creating errors in the ContextFactory:
The type 'BethanysPieShop.Models.AppDbContextFactory' cannot be used as type parameter 'TContext' in the generic type or method 'IDbContextFactory<TContext>'. There is no implicit reference conversion from 'BethanysPieShop.Models.AppDbContextFactory' to 'Microsoft.EntityFrameworkCore.DbContext'. on code line: public class AppDbContextFactory : IDbContextFactory<AppDbContextFactory> And : The type 'BethanysPieShop.Models.AppDbContextFactory' cannot be used as type parameter 'TContext' in the generic type or method 'DbContextOptionsBuilder<TContext>'. There is no implicit reference conversion from 'BethanysPieShop.Models.AppDbContextFactory' to 'Microsoft.EntityFrameworkCore.DbContext'. On code line: var optionsBuilder = new DbContextOptionsBuilder<AppDbContextFactory>(); And 'AppDbContextFactory' does not contain a constructor that takes 1 arguments On code Line: return new AppDbContextFactory(optionsBuilder.Options);
I cant help but think all these are related. I just don't know enough yet to know where to look?