ReportServerTempDBContext.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. using System;
  2. using System.Collections.Generic;
  3. using CodeFirstExistingDatabaseSample.ReportServerTempDB.Models;
  4. using Microsoft.EntityFrameworkCore;
  5. using Microsoft.EntityFrameworkCore.Metadata;
  6. namespace CodeFirstExistingDatabaseSample
  7. {
  8. public partial class ReportServerTempDBContext : DbContext
  9. {
  10. public ReportServerTempDBContext()
  11. {
  12. }
  13. public ReportServerTempDBContext(DbContextOptions<ReportServerTempDBContext> options)
  14. : base(options)
  15. {
  16. }
  17. public virtual DbSet<ChunkDatum> ChunkData { get; set; } = null!;
  18. public virtual DbSet<ChunkSegmentMapping> ChunkSegmentMappings { get; set; } = null!;
  19. public virtual DbSet<DbupgradeHistory> DbupgradeHistories { get; set; } = null!;
  20. public virtual DbSet<ExecutionCache> ExecutionCaches { get; set; } = null!;
  21. public virtual DbSet<PersistedStream> PersistedStreams { get; set; } = null!;
  22. public virtual DbSet<Segment> Segments { get; set; } = null!;
  23. public virtual DbSet<SegmentedChunk> SegmentedChunks { get; set; } = null!;
  24. public virtual DbSet<SessionDatum> SessionData { get; set; } = null!;
  25. public virtual DbSet<SessionLock> SessionLocks { get; set; } = null!;
  26. public virtual DbSet<SnapshotDatum> SnapshotData { get; set; } = null!;
  27. public virtual DbSet<TempCatalog> TempCatalogs { get; set; } = null!;
  28. public virtual DbSet<TempDataSet> TempDataSets { get; set; } = null!;
  29. public virtual DbSet<TempDataSource> TempDataSources { get; set; } = null!;
  30. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  31. {
  32. if (!optionsBuilder.IsConfigured)
  33. {
  34. optionsBuilder.UseSqlServer("Server=192.168.110.161;User ID=sa;Password=sa;Database=ReportServerTempDB;Trusted_Connection=False;");
  35. }
  36. }
  37. protected override void OnModelCreating(ModelBuilder modelBuilder)
  38. {
  39. modelBuilder.UseCollation("Latin1_General_CI_AS_KS_WS");
  40. modelBuilder.Entity<ChunkDatum>(entity =>
  41. {
  42. entity.HasKey(e => e.ChunkId)
  43. .IsClustered(false);
  44. entity.HasIndex(e => new { e.SnapshotDataId, e.ChunkType, e.ChunkName }, "IX_ChunkData")
  45. .IsUnique()
  46. .IsClustered();
  47. entity.Property(e => e.ChunkId)
  48. .ValueGeneratedNever()
  49. .HasColumnName("ChunkID");
  50. entity.Property(e => e.ChunkName).HasMaxLength(260);
  51. entity.Property(e => e.Content).HasColumnType("image");
  52. entity.Property(e => e.MimeType).HasMaxLength(260);
  53. entity.Property(e => e.SnapshotDataId).HasColumnName("SnapshotDataID");
  54. });
  55. modelBuilder.Entity<ChunkSegmentMapping>(entity =>
  56. {
  57. entity.HasKey(e => new { e.ChunkId, e.SegmentId });
  58. entity.ToTable("ChunkSegmentMapping");
  59. entity.HasIndex(e => e.SegmentId, "IX_ChunkSegmentMapping_SegmentId");
  60. entity.HasIndex(e => new { e.ChunkId, e.StartByte }, "UNIQ_ChunkId_StartByte")
  61. .IsUnique();
  62. });
  63. modelBuilder.Entity<DbupgradeHistory>(entity =>
  64. {
  65. entity.HasKey(e => e.UpgradeId);
  66. entity.ToTable("DBUpgradeHistory");
  67. entity.Property(e => e.UpgradeId).HasColumnName("UpgradeID");
  68. entity.Property(e => e.DateTime)
  69. .HasColumnType("datetime")
  70. .HasDefaultValueSql("(getdate())");
  71. entity.Property(e => e.DbVersion).HasMaxLength(25);
  72. entity.Property(e => e.User)
  73. .HasMaxLength(128)
  74. .HasDefaultValueSql("(suser_sname())");
  75. });
  76. modelBuilder.Entity<ExecutionCache>(entity =>
  77. {
  78. entity.HasKey(e => e.ExecutionCacheId)
  79. .IsClustered(false);
  80. entity.ToTable("ExecutionCache");
  81. entity.HasIndex(e => new { e.ReportId, e.ParamsHash, e.AbsoluteExpiration }, "IX_CacheLookup");
  82. entity.HasIndex(e => new { e.AbsoluteExpiration, e.ReportId, e.SnapshotDataId }, "IX_ExecutionCache")
  83. .IsUnique()
  84. .IsClustered();
  85. entity.HasIndex(e => e.SnapshotDataId, "IX_SnapshotDataID");
  86. entity.Property(e => e.ExecutionCacheId)
  87. .ValueGeneratedNever()
  88. .HasColumnName("ExecutionCacheID");
  89. entity.Property(e => e.AbsoluteExpiration).HasColumnType("datetime");
  90. entity.Property(e => e.LastUsedTime)
  91. .HasColumnType("datetime")
  92. .HasDefaultValueSql("(getdate())");
  93. entity.Property(e => e.ReportId).HasColumnName("ReportID");
  94. entity.Property(e => e.SnapshotDataId).HasColumnName("SnapshotDataID");
  95. });
  96. modelBuilder.Entity<PersistedStream>(entity =>
  97. {
  98. entity.HasKey(e => new { e.SessionId, e.Index });
  99. entity.ToTable("PersistedStream");
  100. entity.Property(e => e.SessionId)
  101. .HasMaxLength(32)
  102. .IsUnicode(false)
  103. .HasColumnName("SessionID");
  104. entity.Property(e => e.Content).HasColumnType("image");
  105. entity.Property(e => e.Encoding).HasMaxLength(260);
  106. entity.Property(e => e.Error).HasMaxLength(512);
  107. entity.Property(e => e.ExpirationDate).HasColumnType("datetime");
  108. entity.Property(e => e.Extension).HasMaxLength(260);
  109. entity.Property(e => e.MimeType).HasMaxLength(260);
  110. entity.Property(e => e.Name).HasMaxLength(260);
  111. });
  112. modelBuilder.Entity<Segment>(entity =>
  113. {
  114. entity.ToTable("Segment");
  115. entity.HasIndex(e => e.SegmentId, "IX_SegmentMetadata")
  116. .IsUnique();
  117. entity.Property(e => e.SegmentId).HasDefaultValueSql("(newsequentialid())");
  118. });
  119. modelBuilder.Entity<SegmentedChunk>(entity =>
  120. {
  121. entity.ToTable("SegmentedChunk");
  122. entity.HasIndex(e => new { e.ChunkId, e.SnapshotDataId }, "IX_ChunkId_SnapshotDataId");
  123. entity.HasIndex(e => new { e.SnapshotDataId, e.ChunkType, e.ChunkName }, "UNIQ_SnapshotChunkMapping")
  124. .IsUnique();
  125. entity.Property(e => e.ChunkId).HasDefaultValueSql("(newsequentialid())");
  126. entity.Property(e => e.ChunkName).HasMaxLength(260);
  127. entity.Property(e => e.Machine).HasMaxLength(512);
  128. entity.Property(e => e.MimeType).HasMaxLength(260);
  129. });
  130. modelBuilder.Entity<SessionDatum>(entity =>
  131. {
  132. entity.HasNoKey();
  133. entity.HasIndex(e => e.SessionId, "IDX_SessionData")
  134. .IsUnique()
  135. .IsClustered();
  136. entity.HasIndex(e => e.EditSessionId, "IX_EditSessionID");
  137. entity.HasIndex(e => e.Expiration, "IX_SessionCleanup");
  138. entity.HasIndex(e => e.SnapshotDataId, "IX_SessionSnapshotID");
  139. entity.Property(e => e.CreationTime).HasColumnType("datetime");
  140. entity.Property(e => e.DataSourceInfo).HasColumnType("image");
  141. entity.Property(e => e.EditSessionId)
  142. .HasMaxLength(32)
  143. .IsUnicode(false)
  144. .HasColumnName("EditSessionID");
  145. entity.Property(e => e.EffectiveParams).HasColumnType("ntext");
  146. entity.Property(e => e.Expiration).HasColumnType("datetime");
  147. entity.Property(e => e.HistoryDate).HasColumnType("datetime");
  148. entity.Property(e => e.OwnerId).HasColumnName("OwnerID");
  149. entity.Property(e => e.ReportDefinitionPath).HasMaxLength(464);
  150. entity.Property(e => e.ReportPath).HasMaxLength(464);
  151. entity.Property(e => e.SessionId)
  152. .HasMaxLength(32)
  153. .IsUnicode(false)
  154. .HasColumnName("SessionID");
  155. entity.Property(e => e.ShowHideInfo).HasColumnType("image");
  156. entity.Property(e => e.SitePath).HasMaxLength(440);
  157. entity.Property(e => e.SnapshotDataId).HasColumnName("SnapshotDataID");
  158. entity.Property(e => e.SnapshotExpirationDate).HasColumnType("datetime");
  159. });
  160. modelBuilder.Entity<SessionLock>(entity =>
  161. {
  162. entity.HasNoKey();
  163. entity.ToTable("SessionLock");
  164. entity.HasIndex(e => e.SessionId, "IDX_SessionLock")
  165. .IsUnique()
  166. .IsClustered();
  167. entity.Property(e => e.SessionId)
  168. .HasMaxLength(32)
  169. .IsUnicode(false)
  170. .HasColumnName("SessionID");
  171. });
  172. modelBuilder.Entity<SnapshotDatum>(entity =>
  173. {
  174. entity.HasNoKey();
  175. entity.HasIndex(e => new { e.PermanentRefcount, e.ExpirationDate }, "IS_SnapshotExpiration");
  176. entity.HasIndex(e => new { e.PermanentRefcount, e.TransientRefcount }, "IX_SnapshotCleaning");
  177. entity.HasIndex(e => new { e.SnapshotDataId, e.ParamsHash }, "IX_SnapshotData")
  178. .IsClustered();
  179. entity.Property(e => e.CreatedDate).HasColumnType("datetime");
  180. entity.Property(e => e.Description).HasMaxLength(512);
  181. entity.Property(e => e.EffectiveParams).HasColumnType("ntext");
  182. entity.Property(e => e.ExpirationDate).HasColumnType("datetime");
  183. entity.Property(e => e.IsCached).HasDefaultValueSql("((0))");
  184. entity.Property(e => e.Machine).HasMaxLength(512);
  185. entity.Property(e => e.QueryParams).HasColumnType("ntext");
  186. entity.Property(e => e.SnapshotDataId).HasColumnName("SnapshotDataID");
  187. });
  188. modelBuilder.Entity<TempCatalog>(entity =>
  189. {
  190. entity.HasKey(e => new { e.EditSessionId, e.ContextPath });
  191. entity.ToTable("TempCatalog");
  192. entity.HasIndex(e => e.ExpirationTime, "IX_Cleanup");
  193. entity.HasIndex(e => e.TempCatalogId, "UNIQ_TempCatalogID")
  194. .IsUnique();
  195. entity.Property(e => e.EditSessionId)
  196. .HasMaxLength(32)
  197. .IsUnicode(false)
  198. .HasColumnName("EditSessionID");
  199. entity.Property(e => e.ContextPath).HasMaxLength(425);
  200. entity.Property(e => e.CreationTime).HasColumnType("datetime");
  201. entity.Property(e => e.DataCacheHash).HasMaxLength(64);
  202. entity.Property(e => e.ExpirationTime).HasColumnType("datetime");
  203. entity.Property(e => e.Name).HasMaxLength(425);
  204. entity.Property(e => e.OwnerId).HasColumnName("OwnerID");
  205. entity.Property(e => e.TempCatalogId).HasColumnName("TempCatalogID");
  206. });
  207. modelBuilder.Entity<TempDataSet>(entity =>
  208. {
  209. entity.HasKey(e => e.Id)
  210. .HasName("PK_TempDataSet")
  211. .IsClustered(false);
  212. entity.HasIndex(e => e.LinkId, "IX_DataSetLinkID");
  213. entity.HasIndex(e => new { e.ItemId, e.Name }, "IX_TempDataSet_ItemID_Name")
  214. .IsClustered();
  215. entity.Property(e => e.Id)
  216. .ValueGeneratedNever()
  217. .HasColumnName("ID");
  218. entity.Property(e => e.ItemId).HasColumnName("ItemID");
  219. entity.Property(e => e.LinkId).HasColumnName("LinkID");
  220. entity.Property(e => e.Name).HasMaxLength(260);
  221. entity.HasOne(d => d.Item)
  222. .WithMany(p => p.TempDataSets)
  223. .HasPrincipalKey(p => p.TempCatalogId)
  224. .HasForeignKey(d => d.ItemId)
  225. .OnDelete(DeleteBehavior.ClientSetNull)
  226. .HasConstraintName("FK_DataSetItemID");
  227. });
  228. modelBuilder.Entity<TempDataSource>(entity =>
  229. {
  230. entity.HasKey(e => e.Dsid)
  231. .HasName("PK_DataSource");
  232. entity.HasIndex(e => e.ItemId, "IX_DataSourceItemID");
  233. entity.Property(e => e.Dsid)
  234. .ValueGeneratedNever()
  235. .HasColumnName("DSID");
  236. entity.Property(e => e.ConnectionString).HasColumnType("image");
  237. entity.Property(e => e.Extension).HasMaxLength(260);
  238. entity.Property(e => e.ItemId).HasColumnName("ItemID");
  239. entity.Property(e => e.Name).HasMaxLength(260);
  240. entity.Property(e => e.OriginalConnectionString).HasColumnType("image");
  241. entity.Property(e => e.Password).HasColumnType("image");
  242. entity.Property(e => e.Prompt).HasColumnType("ntext");
  243. entity.Property(e => e.UserName).HasColumnType("image");
  244. entity.HasOne(d => d.Item)
  245. .WithMany(p => p.TempDataSources)
  246. .HasPrincipalKey(p => p.TempCatalogId)
  247. .HasForeignKey(d => d.ItemId)
  248. .OnDelete(DeleteBehavior.ClientSetNull)
  249. .HasConstraintName("FK_DataSourceItemID");
  250. });
  251. OnModelCreatingPartial(modelBuilder);
  252. }
  253. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  254. }
  255. }