| | | 1 | | #region Usings |
| | | 2 | | using ZhEaIsNsAaBn.DbSeeder.Registrations; |
| | | 3 | | #endregion |
| | | 4 | | |
| | | 5 | | namespace ZhEaIsNsAaBn.DbSeeder; |
| | | 6 | | |
| | | 7 | | /// <summary>Registers seed migrations for a context.</summary> |
| | | 8 | | public static class DbSeederRegistration |
| | | 9 | | { |
| | | 10 | | /// <summary>Starts the seed-migration registration of <typeparamref name="TDbContext"/>. Finish with <c>Build()</c> |
| | | 11 | | /// <typeparam name="TDbContext">The context the migrations belong to.</typeparam> |
| | | 12 | | /// <param name="services">The service collection.</param> |
| | | 13 | | /// <returns>The builder.</returns> |
| | | 14 | | /// <exception cref="ArgumentNullException"><paramref name="services"/> is <see langword="null"/>.</exception> |
| | | 15 | | /// <example> |
| | | 16 | | /// <code> |
| | | 17 | | /// services.AddDbSeeder<AppDbContext>() |
| | | 18 | | /// .FromAssembly( typeof( AppDbContext ).Assembly ) |
| | | 19 | | /// .Configure( options => |
| | | 20 | | /// { |
| | | 21 | | /// options.SystemUser( 1, "system" ); |
| | | 22 | | /// options.ApplyConfigurationsFromAssembly( typeof( AppDbContext ).Assembly ); |
| | | 23 | | /// options.Entity<Country>().MatchBy( x => x.IsoCode ); |
| | | 24 | | /// } ) |
| | | 25 | | /// .UseSqlServer() |
| | | 26 | | /// .Build(); |
| | | 27 | | /// </code> |
| | | 28 | | /// </example> |
| | | 29 | | public static IDbSeederBuilder<TDbContext> AddDbSeeder< TDbContext >( this IServiceCollection services ) |
| | | 30 | | where TDbContext : DbContext |
| | | 31 | | { |
| | 596 | 32 | | ArgumentNullException.ThrowIfNull( services ); |
| | | 33 | | |
| | 596 | 34 | | return new DbSeederBuilder<TDbContext>( services ); |
| | | 35 | | } |
| | | 36 | | } |