)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » ApplicationDbContext (Ia.Cl)

Public general use code classes and xml files that we've compiled and used over the years:

    1: using Microsoft.AspNetCore.Identity;
    2: using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
    3: using Microsoft.EntityFrameworkCore;
    4:  
    5: namespace Ia.Cl
    6: {
    7:     ////////////////////////////////////////////////////////////////////////////
    8:  
    9:     /// <summary publish="true">
   10:     ///
   11:     /// </summary>
   12:     /// 
   13:     /// <remarks> 
   14:     /// Copyright © 2006-2025 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   15:     ///
   16:     /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
   17:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   18:     ///
   19:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   20:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   21:     /// 
   22:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   23:     /// 
   24:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   25:     /// </remarks> 
   26:     public class ApplicationDbContext : IdentityDbContext<IdentityUser>
   27:     {
   28:         // public DbSet<Ia.Cl.Models.Domain> Domains { get; set; }
   29:  
   30:         // public DbSet<IdentityUser> ApplicationUsers { get; set; }
   31:  
   32:         ////////////////////////////////////////////////////////////////////////////
   33:  
   34:         /// <summary>
   35:         ///
   36:         /// </summary>
   37:         public ApplicationDbContext(DbContextOptions options) : base(options)
   38:         {
   39:         }
   40:  
   41:         ////////////////////////////////////////////////////////////////////////////
   42:  
   43:         /// <summary>
   44:         ///
   45:         /// </summary>
   46:         protected override void OnModelCreating(ModelBuilder builder)
   47:         {
   48:             base.OnModelCreating(builder);
   49:             // Customize the ASP.NET Identity model and override the defaults if needed.
   50:             // For example, you can rename the ASP.NET Identity table names and more.
   51:             // Add your customizations after calling base.OnModelCreating(builder);
   52:  
   53:             //builder.Entity<ApplicationUser>().HasNoKey();
   54:         }
   55:  
   56:         ////////////////////////////////////////////////////////////////////////////
   57:  
   58:         /// <summary>
   59:         ///
   60:         /// </summary>
   61:         public static void CreateTables()
   62:         {
   63:             /*
   64:             using (var db = new Ia.Cl.IaDbContext())
   65:             {
   66:                 var databaseCreator = (RelationalDatabaseCreator)db.Database.GetService<IDatabaseCreator>();
   67: 
   68:                 databaseCreator.CreateTables();
   69:             }
   70:             */
   71:         }
   72:  
   73:         ////////////////////////////////////////////////////////////////////////////
   74:  
   75:         /// <summary>
   76:         ///
   77:         /// </summary>
   78:         protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
   79:         {
   80:             optionsBuilder.UseSqlServer(Ia.Cl.Models.ApplicationConfiguration.GetSetting("ConnectionStrings:DefaultConnection"));
   81:  
   82:             base.OnConfiguring(optionsBuilder);
   83:         }
   84:  
   85:         ////////////////////////////////////////////////////////////////////////////
   86:         ////////////////////////////////////////////////////////////////////////////
   87:     }
   88:  
   89:     ////////////////////////////////////////////////////////////////////////////
   90:     ////////////////////////////////////////////////////////////////////////////
   91: }