123456789101112131415161718192021222324252627 |
- using System.Diagnostics;
- using Microsoft.EntityFrameworkCore;
- using Microsoft.EntityFrameworkCore.Design;
- using Microsoft.Extensions.Configuration;
- using VCommonCoreExample.Configuration;
- namespace VCommonCoreExample.EntityFrameworkCore
- {
- /* This class is needed to run "dotnet ef ..." commands from command line on development. Not used anywhere else */
- public class ExampleDbContextFactory : IDesignTimeDbContextFactory<ExampleDbContext>
- {
- public ExampleDbContext CreateDbContext(string[] args)
- {
- Debugger.Launch();
- Debugger.Break();
- var builder = new DbContextOptionsBuilder<ExampleDbContext>();
- var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder());
- ExampleDbContextConfig.Configure(builder, configuration.GetConnectionString(ProjectConst.ConnectionStringName));
- return new ExampleDbContext(builder.Options);
- }
- }
- }
|