@@ -16,32 +16,7 @@ namespace IoTSharp.EntityFrameworkCore.MongoDB.Extensions;
16
16
/// </remarks>
17
17
public static class MongoDBDbContextOptionsExtensions
18
18
{
19
- /// <summary>
20
- /// Configures the context to connect to an Azure MongoDB database.
21
- /// </summary>
22
- /// <remarks>
23
- /// See <see href="https://aka.ms/efcore-docs-dbcontext-options">Using DbContextOptions</see>, and
24
- /// <see href="https://aka.ms/efcore-docs-MongoDB">Accessing Azure MongoDB DB with EF Core</see> for more information and examples.
25
- /// </remarks>
26
- /// <typeparam name="TContext">The type of context to be configured.</typeparam>
27
- /// <param name="optionsBuilder">The builder being used to configure the context.</param>
28
- /// <param name="accountEndpoint">The account end-point to connect to.</param>
29
- /// <param name="accountKey">The account key.</param>
30
- /// <param name="databaseName">The database name.</param>
31
- /// <param name="MongoDBOptionsAction">An optional action to allow additional MongoDB-specific configuration.</param>
32
- /// <returns>The options builder so that further configuration can be chained.</returns>
33
- public static DbContextOptionsBuilder < TContext > UseMongoDB < TContext > (
34
- this DbContextOptionsBuilder < TContext > optionsBuilder ,
35
- string accountEndpoint ,
36
- string accountKey ,
37
- string databaseName ,
38
- Action < MongoDBDbContextOptionsBuilder > ? MongoDBOptionsAction = null )
39
- where TContext : DbContext
40
- => ( DbContextOptionsBuilder < TContext > ) ( ( DbContextOptionsBuilder ) optionsBuilder ) . UseMongoDB (
41
- accountEndpoint ,
42
- accountKey ,
43
- databaseName ,
44
- MongoDBOptionsAction ) ;
19
+
45
20
46
21
/// <summary>
47
22
/// Configures the context to connect to an Azure MongoDB database.
@@ -51,30 +26,22 @@ public static DbContextOptionsBuilder<TContext> UseMongoDB<TContext>(
51
26
/// <see href="https://aka.ms/efcore-docs-MongoDB">Accessing Azure MongoDB DB with EF Core</see> for more information and examples.
52
27
/// </remarks>
53
28
/// <param name="optionsBuilder">The builder being used to configure the context.</param>
54
- /// <param name="accountEndpoint">The account end-point to connect to.</param>
55
- /// <param name="accountKey">The account key.</param>
56
- /// <param name="databaseName">The database name.</param>
29
+ /// <param name="connectionString"></param>
57
30
/// <param name="MongoDBOptionsAction">An optional action to allow additional MongoDB-specific configuration.</param>
58
31
/// <returns>The options builder so that further configuration can be chained.</returns>
59
32
public static DbContextOptionsBuilder UseMongoDB (
60
33
this DbContextOptionsBuilder optionsBuilder ,
61
- string accountEndpoint ,
62
- string accountKey ,
63
- string databaseName ,
34
+ string connectionString ,
64
35
Action < MongoDBDbContextOptionsBuilder > ? MongoDBOptionsAction = null )
65
36
{
66
37
Check . NotNull ( optionsBuilder , nameof ( optionsBuilder ) ) ;
67
- Check . NotNull ( accountEndpoint , nameof ( accountEndpoint ) ) ;
68
- Check . NotEmpty ( accountKey , nameof ( accountKey ) ) ;
69
- Check . NotEmpty ( databaseName , nameof ( databaseName ) ) ;
38
+ Check . NotEmpty ( connectionString , nameof ( connectionString ) ) ;
70
39
71
40
var extension = optionsBuilder . Options . FindExtension < MongoDBOptionsExtension > ( )
72
41
?? new MongoDBOptionsExtension ( ) ;
73
42
74
43
extension = extension
75
- . WithAccountEndpoint ( accountEndpoint )
76
- . WithAccountKey ( accountKey )
77
- . WithDatabaseName ( databaseName ) ;
44
+ . WithConnectionString ( connectionString ) ;
78
45
79
46
( ( IDbContextOptionsBuilderInfrastructure ) optionsBuilder ) . AddOrUpdateExtension ( extension ) ;
80
47
0 commit comments