Ejemplo n.º 1
0
        public static IServiceProvider ConfigureServices()
        {
            //setup our DI
            var serviceProvider = new ServiceCollection()
                                  .AddLogging()
                                  .AddDbContext <DataContext>(options => options.UseSqlite(SqliteConnection))
                                  .AddScoped(typeof(IRepository <>), typeof(RepositoryImpl <>))
                                  .AddScoped(typeof(IRepository <,>), typeof(RepositoryImpl <,>))
                                  .BuildServiceProvider();

            // database
            var context = serviceProvider.GetService <DataContext>();

            SqliteUtils.CreateDatabaseIfNotExists(context, DATABASE_NAME);

            return(serviceProvider);
        }