mirror of https://github.com/abpframework/abp
				
				
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							30 lines
						
					
					
						
							943 B
						
					
					
				
			
		
		
	
	
							30 lines
						
					
					
						
							943 B
						
					
					
				| using System.IO;
 | |
| using Microsoft.EntityFrameworkCore;
 | |
| using Microsoft.EntityFrameworkCore.Design;
 | |
| using Microsoft.Extensions.Configuration;
 | |
| 
 | |
| namespace MyCompanyName.MyProjectName.Host
 | |
| {
 | |
|     public class DemoAppDbContextFactory : IDesignTimeDbContextFactory<DemoAppDbContext>
 | |
|     {
 | |
|         public DemoAppDbContext CreateDbContext(string[] args)
 | |
|         {
 | |
|             var configuration = BuildConfiguration();
 | |
| 
 | |
|             var builder = new DbContextOptionsBuilder<DemoAppDbContext>()
 | |
|                 .UseSqlServer(configuration.GetConnectionString("Default"));
 | |
| 
 | |
|             return new DemoAppDbContext(builder.Options);
 | |
|         }
 | |
| 
 | |
|         private static IConfigurationRoot BuildConfiguration()
 | |
|         {
 | |
|             var builder = new ConfigurationBuilder()
 | |
|                 .SetBasePath(Directory.GetCurrentDirectory())
 | |
|                 .AddJsonFile("appsettings.json", optional: false);
 | |
| 
 | |
|             return builder.Build();
 | |
|         }
 | |
|     }
 | |
| }
 |