26 lines
		
	
	
		
			888 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			888 B
		
	
	
	
		
			C#
		
	
	
	
	
	
| using Core.Blueprint.DAL.SQLServer.Entities;
 | |
| using Core.Blueprint.SQLServer.Entities;
 | |
| using Microsoft.EntityFrameworkCore;
 | |
| 
 | |
| namespace Core.Blueprint.DAL.SQLServer.Context
 | |
| {
 | |
|     public sealed class SqlServerContext : DbContext
 | |
|     {
 | |
|         public SqlServerContext(DbContextOptions<SqlServerContext> options) : base(options) { }
 | |
|         public DbSet<Sample> UserProjects { get; set; }
 | |
| 
 | |
|         protected override void OnModelCreating(ModelBuilder modelBuilder)
 | |
|         {
 | |
|             foreach (var entityType in modelBuilder.Model.GetEntityTypes()
 | |
|                 .Where(t => typeof(BaseSQLAdapter).IsAssignableFrom(t.ClrType)))
 | |
|             {
 | |
|                 modelBuilder.Entity(entityType.ClrType)
 | |
|                     .HasKey("Id");
 | |
| 
 | |
|                 modelBuilder.Entity(entityType.ClrType).Property("Status")
 | |
|                     .HasConversion<string>();
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 | 
