Skip to content

Commit 0ab838a

Browse files
committed
Remove DbContextFactoryOptions
Part of #8164
1 parent c6a0602 commit 0ab838a

File tree

5 files changed

+34
-43
lines changed

5 files changed

+34
-43
lines changed

src/EFCore.Design/Design/Internal/DbContextOperations.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ where i.GetTypeInfo().IsGenericType
110110
contexts.Add(
111111
context,
112112
() => ((IDbContextFactory<DbContext>)Activator.CreateInstance(factory.AsType())).Create(
113-
CreateFactoryOptions()));
113+
Array.Empty<string>()));
114114
}
115115
}
116116

@@ -181,7 +181,7 @@ private Func<DbContext> FindContextFactory(Type contextType)
181181
}
182182

183183
return () => ((IDbContextFactory<DbContext>)Activator.CreateInstance(factory)).Create(
184-
CreateFactoryOptions());
184+
Array.Empty<string>());
185185
}
186186

187187
private KeyValuePair<Type, Func<DbContext>> FindContextType(string name)
@@ -249,14 +249,5 @@ private static IDictionary<Type, Func<DbContext>> FilterTypes(
249249
|| string.Equals(t.Key.AssemblyQualifiedName, name, comparisonType))
250250
.ToDictionary(t => t.Key, t => t.Value);
251251
}
252-
253-
private DbContextFactoryOptions CreateFactoryOptions()
254-
=> new DbContextFactoryOptions
255-
{
256-
ApplicationBasePath = AppContext.BaseDirectory,
257-
ContentRootPath = Directory.GetCurrentDirectory(),
258-
EnvironmentName = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")
259-
?? "Development"
260-
};
261252
}
262253
}

src/EFCore/Infrastructure/DbContextFactoryOptions.cs

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/EFCore/Infrastructure/IDbContextFactory.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Microsoft.EntityFrameworkCore.Infrastructure
1010
/// design-time services for context types that do not have a public default constructor. At design-time,
1111
/// derived <see cref="DbContext" /> instances can be created in order to enable specific design-time
1212
/// experiences such as Migrations. Design-time services will automatically discover implementations of
13-
/// this interface that are in the same assembly as the derived context.
13+
/// this interface that are in the startup assembly or the same assembly as the derived context.
1414
/// </summary>
1515
/// <typeparam name="TContext">The type of the context.</typeparam>
1616
public interface IDbContextFactory<out TContext>
@@ -19,8 +19,8 @@ public interface IDbContextFactory<out TContext>
1919
/// <summary>
2020
/// Creates a new instance of a derived context.
2121
/// </summary>
22-
/// <param name="options"> Information about the environment an application is running in. </param>
22+
/// <param name="args"> Arguments provided by the design-time service. </param>
2323
/// <returns> An instance of <typeparamref name="TContext" />. </returns>
24-
TContext Create([NotNull] DbContextFactoryOptions options);
24+
TContext Create([NotNull] string[] args);
2525
}
2626
}

src/EFCore/breakingchanges.netcore.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,5 +504,19 @@
504504
"TypeId": "public abstract class Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor : Remotion.Linq.QueryModelVisitorBase",
505505
"MemberId": "public static System.Boolean IsPropertyMethod(System.Reflection.MethodInfo methodInfo)",
506506
"Kind": "Removal"
507+
},
508+
{
509+
"TypeId": "public class Microsoft.EntityFrameworkCore.Infrastructure.DbContextFactoryOptions",
510+
"Kind": "Removal"
511+
},
512+
{
513+
"TypeId": "public interface Microsoft.EntityFrameworkCore.Infrastructure.IDbContextFactory<T0> where T0 : Microsoft.EntityFrameworkCore.DbContext",
514+
"MemberId": "T0 Create(Microsoft.EntityFrameworkCore.Infrastructure.DbContextFactoryOptions options)",
515+
"Kind": "Removal"
516+
},
517+
{
518+
"TypeId": "public interface Microsoft.EntityFrameworkCore.Infrastructure.IDbContextFactory<T0> where T0 : Microsoft.EntityFrameworkCore.DbContext",
519+
"MemberId": "T0 Create(System.String[] args)",
520+
"Kind": "Addition"
507521
}
508522
]

src/EFCore/breakingchanges.netframework.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,5 +504,19 @@
504504
"TypeId": "public abstract class Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor : Remotion.Linq.QueryModelVisitorBase",
505505
"MemberId": "public static System.Boolean IsPropertyMethod(System.Reflection.MethodInfo methodInfo)",
506506
"Kind": "Removal"
507-
}
507+
},
508+
{
509+
"TypeId": "public class Microsoft.EntityFrameworkCore.Infrastructure.DbContextFactoryOptions",
510+
"Kind": "Removal"
511+
},
512+
{
513+
"TypeId": "public interface Microsoft.EntityFrameworkCore.Infrastructure.IDbContextFactory<T0> where T0 : Microsoft.EntityFrameworkCore.DbContext",
514+
"MemberId": "T0 Create(Microsoft.EntityFrameworkCore.Infrastructure.DbContextFactoryOptions options)",
515+
"Kind": "Removal"
516+
},
517+
{
518+
"TypeId": "public interface Microsoft.EntityFrameworkCore.Infrastructure.IDbContextFactory<T0> where T0 : Microsoft.EntityFrameworkCore.DbContext",
519+
"MemberId": "T0 Create(System.String[] args)",
520+
"Kind": "Addition"
521+
}
508522
]

0 commit comments

Comments
 (0)