gRPC, ядро EF, SQLite с различными базами данных

#sqlite #entity-framework #grpc

Вопрос:

Я хотел бы использовать gRPC, EF Core и SQLite с разными базами данных. Я определил контекст БД приложения следующим образом:

 public class ApplicationDbContext : DbContext
    {
        private string _databasePath;

        public ApplicationDbContext(string databasePath)
        {
            _databasePath = databasePath;
        }

        protected override void OnConfiguring(DbContextOptionsBuilder options)
            => options.UseSqlite($"Data Source={_databasePath}");

    }
 

Я не знаю, как перенести путь к базе данных в контекст.

 public class Startup
    {
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddGrpc();

            services.AddDbContext<ApplicationDbContext>();

        }

...
}
 

Эта конфигурация дает исключение.