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

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

    1: using Microsoft.EntityFrameworkCore;
    2: using Microsoft.EntityFrameworkCore.Infrastructure;
    3: using Microsoft.EntityFrameworkCore.Storage;
    4: using System.Configuration;
    5:  
    6: namespace Ia.TentPlay
    7: {
    8:     ////////////////////////////////////////////////////////////////////////////
    9:  
   10:     /// <summary publish="true">
   11:     ///
   12:     /// </summary>
   13:     /// 
   14:     /// <remarks> 
   15:     /// Copyright © 2006-2025 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   16:     ///
   17:     /// 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
   18:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   19:     ///
   20:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   21:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   22:     /// 
   23:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   24:     /// 
   25:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   26:     /// </remarks> 
   27:     public class Db : DbContext
   28:     {
   29:         ////////////////////////////////////////////////////////////////////////////
   30:  
   31:         /// <summary>
   32:         ///
   33:         /// </summary>
   34:         public Db() { }
   35:  
   36:         ////////////////////////////////////////////////////////////////////////////
   37:  
   38:         /// <summary>
   39:         ///
   40:         /// </summary>
   41:         public Db(DbContextOptions<DbContext> options) : base(options) { }
   42:  
   43:         /// <summary/>
   44:         public DbSet<Ia.TentPlay.Cl.Models.Trek.FeatureDesignation> FeatureDesignations { get; set; }
   45:  
   46:         /// <summary/>
   47:         public DbSet<Ia.TentPlay.Cl.Models.Trek.Feature> Features { get; set; }
   48:  
   49:         /// <summary/>
   50:         public DbSet<Ia.TentPlay.Cl.Models.Memorise.Score> Scores { get; set; }
   51:  
   52:         ////////////////////////////////////////////////////////////////////////////
   53:  
   54:         /// <summary>
   55:         ///
   56:         /// </summary>
   57:         public static void CreateTables()
   58:         {
   59:             using (var db = new Ia.TentPlay.Db())
   60:             {
   61:                 var databaseCreator = (RelationalDatabaseCreator)db.Database.GetService<IDatabaseCreator>();
   62:  
   63:                 databaseCreator.CreateTables();
   64:             }
   65:         }
   66:         ////////////////////////////////////////////////////////////////////////////
   67:  
   68:         /// <summary>
   69:         ///
   70:         /// </summary>
   71:         protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
   72:         {
   73:             optionsBuilder.UseSqlServer(Ia.Cl.Models.ApplicationConfiguration.GetSetting("ConnectionStrings:DefaultConnection"));//.UseInMemoryDatabase("Test");
   74:  
   75:             base.OnConfiguring(optionsBuilder);
   76:         }
   77:  
   78:         ////////////////////////////////////////////////////////////////////////////
   79:         ////////////////////////////////////////////////////////////////////////////
   80:     }
   81: }