Skip to content

Commit ac77903

Browse files
committed
Removing MongoDbConnection.FromConfig
If an application needs it, it could implement its own helper to get the value and pass it into FromConnectionString
1 parent 6b555e8 commit ac77903

File tree

5 files changed

+1
-50
lines changed

5 files changed

+1
-50
lines changed

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public class MyContext : MongoDbContext
8888
While it mostly feels the same as creating contexts in Entity Framework, there are a number of differences still with the biggest being in the creation of contexts.
8989
The `IMongoDbConnection` is the core infrastructure that allows connection to MongoDB and is required to instantiate a context.
9090

91-
You can create an instance of a connection in many ways:
91+
You can create an instance of a connection in two ways:
9292
```csharp
9393
IMongoDbConnection connection;
9494

@@ -97,9 +97,6 @@ connection = MongoDbConnection.FromUrl(new MongoUrl("mongodb://localhost:27017/M
9797
9898
//FromConnectionString
9999
connection = MongoDbConnection.FromConnectionString("mongodb://localhost:27017/MyDatabase");
100-
101-
//FromConfig (Note: .NET Framework only)
102-
connection = MongoDbConnection.FromConfig("MyConnectionStringName");
103100
```
104101

105102
### Special Queries

src/MongoFramework/MongoDbConnection.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,6 @@ public static MongoDbConnection FromConnectionString(string connectionString)
5050
return FromUrl(new MongoUrl(connectionString));
5151
}
5252

53-
#if (!NETCOREAPP2_0 && !NETCOREAPP3_0)
54-
public static MongoDbConnection FromConfig(string connectionName)
55-
{
56-
var connectionStringConfig = System.Configuration.ConfigurationManager.ConnectionStrings[connectionName];
57-
58-
if (connectionStringConfig != null)
59-
{
60-
var mongoUrl = MongoUrl.Create(connectionStringConfig.ConnectionString);
61-
return FromUrl(mongoUrl);
62-
}
63-
64-
return null;
65-
}
66-
#endif
67-
6853
public IMongoDatabase GetDatabase()
6954
{
7055
if (IsDisposed)

src/MongoFramework/MongoFramework.csproj

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@
88
<PackageTags>$(PackageBaseTags)</PackageTags>
99
<Authors>James Turner</Authors>
1010
</PropertyGroup>
11-
12-
<PropertyGroup Condition="'$(TargetFramework)'=='NETCOREAPP2_0'">
13-
<DefineConstants>NETCOREAPP2_0</DefineConstants>
14-
</PropertyGroup>
15-
16-
<PropertyGroup Condition="'$(TargetFramework)'=='netcoreapp3.0'">
17-
<DefineConstants>NETCOREAPP3_0</DefineConstants>
18-
</PropertyGroup>
1911

2012
<ItemGroup>
2113
<PackageReference Include="MongoDB.Driver" Version="2.9.2" />

tests/MongoFramework.Tests/MongoDbConnectionTests.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,6 @@ namespace MongoFramework.Tests
66
[TestClass]
77
public class MongoDbConnectionTests
88
{
9-
#if (!NETCOREAPP2_0 && !NETCOREAPP3_0)
10-
[TestMethod]
11-
public void ConnectionFromConfig()
12-
{
13-
var connection = MongoDbConnection.FromConfig("MongoFrameworkTests");
14-
Assert.IsNotNull(connection);
15-
}
16-
[TestMethod]
17-
public void InvalidConfigForConnection()
18-
{
19-
var connection = MongoDbConnection.FromConfig("ThisConfigNameDoesntExist");
20-
Assert.IsNull(connection);
21-
}
22-
#endif
23-
249
[TestMethod]
2510
public void ConnectionFromConnectionString()
2611
{

tests/MongoFramework.Tests/MongoFramework.Tests.csproj

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@
77
<IsPackable>false</IsPackable>
88
</PropertyGroup>
99

10-
<PropertyGroup Condition="'$(TargetFramework)'=='netcoreapp2.1'">
11-
<DefineConstants>NETCOREAPP2_0</DefineConstants>
12-
</PropertyGroup>
13-
14-
<PropertyGroup Condition="'$(TargetFramework)'=='netcoreapp3.0'">
15-
<DefineConstants>NETCOREAPP3_0</DefineConstants>
16-
</PropertyGroup>
17-
1810
<ItemGroup>
1911
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
2012
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />

0 commit comments

Comments
 (0)