Calibre_EntityFrameworkCore

Changes

src/.gitattributes 63(+63 -0)

src/.gitignore 363(+363 -0)

src/Calibre.sln 39(+39 -0)

Details

diff --git "a/docs/\320\241\320\276\320\267\320\264\320\260\320\275\320\270\320\265 \320\272\320\276\320\275\321\202\320\265\320\272\321\201\321\202\320\260.txt" "b/docs/\320\241\320\276\320\267\320\264\320\260\320\275\320\270\320\265 \320\272\320\276\320\275\321\202\320\265\320\272\321\201\321\202\320\260.txt"
new file mode 100644
index 0000000..bf00534
--- /dev/null
+++ "b/docs/\320\241\320\276\320\267\320\264\320\260\320\275\320\270\320\265 \320\272\320\276\320\275\321\202\320\265\320\272\321\201\321\202\320\260.txt"
@@ -0,0 +1,9 @@
+
+Процесс генерации контекста 
+
+1) Взят файл БД из Calibe - metadata.db
+
+2) Из БД удалены все View. С ними была ошибка генерации.
+
+3) Команда:
+Scaffold-DbContext "Путь к файлу БД" Microsoft.EntityFrameworkCore.Sqlite -OutputDir Entities
\ No newline at end of file

src/.gitattributes 63(+63 -0)

diff --git a/src/.gitattributes b/src/.gitattributes
new file mode 100644
index 0000000..1ff0c42
--- /dev/null
+++ b/src/.gitattributes
@@ -0,0 +1,63 @@
+###############################################################################
+# Set default behavior to automatically normalize line endings.
+###############################################################################
+* text=auto
+
+###############################################################################
+# Set default behavior for command prompt diff.
+#
+# This is need for earlier builds of msysgit that does not have it on by
+# default for csharp files.
+# Note: This is only used by command line
+###############################################################################
+#*.cs     diff=csharp
+
+###############################################################################
+# Set the merge driver for project and solution files
+#
+# Merging from the command prompt will add diff markers to the files if there
+# are conflicts (Merging from VS is not affected by the settings below, in VS
+# the diff markers are never inserted). Diff markers may cause the following 
+# file extensions to fail to load in VS. An alternative would be to treat
+# these files as binary and thus will always conflict and require user
+# intervention with every merge. To do so, just uncomment the entries below
+###############################################################################
+#*.sln       merge=binary
+#*.csproj    merge=binary
+#*.vbproj    merge=binary
+#*.vcxproj   merge=binary
+#*.vcproj    merge=binary
+#*.dbproj    merge=binary
+#*.fsproj    merge=binary
+#*.lsproj    merge=binary
+#*.wixproj   merge=binary
+#*.modelproj merge=binary
+#*.sqlproj   merge=binary
+#*.wwaproj   merge=binary
+
+###############################################################################
+# behavior for image files
+#
+# image files are treated as binary by default.
+###############################################################################
+#*.jpg   binary
+#*.png   binary
+#*.gif   binary
+
+###############################################################################
+# diff behavior for common document formats
+# 
+# Convert binary document formats to text before diffing them. This feature
+# is only available from the command line. Turn it on by uncommenting the 
+# entries below.
+###############################################################################
+#*.doc   diff=astextplain
+#*.DOC   diff=astextplain
+#*.docx  diff=astextplain
+#*.DOCX  diff=astextplain
+#*.dot   diff=astextplain
+#*.DOT   diff=astextplain
+#*.pdf   diff=astextplain
+#*.PDF   diff=astextplain
+#*.rtf   diff=astextplain
+#*.RTF   diff=astextplain

src/.gitignore 363(+363 -0)

diff --git a/src/.gitignore b/src/.gitignore
new file mode 100644
index 0000000..9491a2f
--- /dev/null
+++ b/src/.gitignore
@@ -0,0 +1,363 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Oo]ut/
+[Ll]og/
+[Ll]ogs/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*.json
+coverage*.xml
+coverage*.info
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
\ No newline at end of file
diff --git a/src/Calibre.Model.Database/Calibre.Model.Database.csproj b/src/Calibre.Model.Database/Calibre.Model.Database.csproj
new file mode 100644
index 0000000..abbf5dc
--- /dev/null
+++ b/src/Calibre.Model.Database/Calibre.Model.Database.csproj
@@ -0,0 +1,23 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Library</OutputType>
+    <TargetFramework>net5.0</TargetFramework>
+    <ApplicationIcon />
+    <StartupObject />
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.10" />
+    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.10">
+      <PrivateAssets>all</PrivateAssets>
+      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
+    </PackageReference>
+    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.10" />
+    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.10">
+      <PrivateAssets>all</PrivateAssets>
+      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
+    </PackageReference>
+  </ItemGroup>
+
+</Project>
diff --git a/src/Calibre.Model.Database/CalibreContext.cs b/src/Calibre.Model.Database/CalibreContext.cs
new file mode 100644
index 0000000..30cbffc
--- /dev/null
+++ b/src/Calibre.Model.Database/CalibreContext.cs
@@ -0,0 +1,843 @@
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata;
+
+#nullable disable
+
+using Calibre.Model.Database.Entities;
+
+namespace Calibre.Model.Database
+{
+    public partial class CalibreContext 
+        : DbContext
+    {
+        #region Sets
+
+        public virtual DbSet<Annotation> Annotations { get; set; }
+        public virtual DbSet<AnnotationsDirtied> AnnotationsDirtieds { get; set; }
+        public virtual DbSet<AnnotationsFt> AnnotationsFts { get; set; }
+        public virtual DbSet<AnnotationsFtsConfig> AnnotationsFtsConfigs { get; set; }
+        public virtual DbSet<AnnotationsFtsDatum> AnnotationsFtsData { get; set; }
+        public virtual DbSet<AnnotationsFtsDocsize> AnnotationsFtsDocsizes { get; set; }
+        public virtual DbSet<AnnotationsFtsIdx> AnnotationsFtsIdxes { get; set; }
+        public virtual DbSet<AnnotationsFtsStemmed> AnnotationsFtsStemmeds { get; set; }
+        public virtual DbSet<AnnotationsFtsStemmedConfig> AnnotationsFtsStemmedConfigs { get; set; }
+        public virtual DbSet<AnnotationsFtsStemmedDatum> AnnotationsFtsStemmedData { get; set; }
+        public virtual DbSet<AnnotationsFtsStemmedDocsize> AnnotationsFtsStemmedDocsizes { get; set; }
+        public virtual DbSet<AnnotationsFtsStemmedIdx> AnnotationsFtsStemmedIdxes { get; set; }
+        public virtual DbSet<Author> Authors { get; set; }
+        public virtual DbSet<Book> Books { get; set; }
+        public virtual DbSet<BooksAuthorsLink> BooksAuthorsLinks { get; set; }
+        public virtual DbSet<BooksLanguagesLink> BooksLanguagesLinks { get; set; }
+        public virtual DbSet<BooksPluginDatum> BooksPluginData { get; set; }
+        public virtual DbSet<BooksPublishersLink> BooksPublishersLinks { get; set; }
+        public virtual DbSet<BooksRatingsLink> BooksRatingsLinks { get; set; }
+        public virtual DbSet<BooksSeriesLink> BooksSeriesLinks { get; set; }
+        public virtual DbSet<BooksTagsLink> BooksTagsLinks { get; set; }
+        public virtual DbSet<Comment> Comments { get; set; }
+        public virtual DbSet<ConversionOption> ConversionOptions { get; set; }
+        public virtual DbSet<CustomColumn> CustomColumns { get; set; }
+        public virtual DbSet<Datum> Data { get; set; }
+        public virtual DbSet<Feed> Feeds { get; set; }
+        public virtual DbSet<Identifier> Identifiers { get; set; }
+        public virtual DbSet<Language> Languages { get; set; }
+        public virtual DbSet<LastReadPosition> LastReadPositions { get; set; }
+        public virtual DbSet<LibraryId> LibraryIds { get; set; }
+        public virtual DbSet<MetadataDirtied> MetadataDirtieds { get; set; }
+        public virtual DbSet<Preference> Preferences { get; set; }
+        public virtual DbSet<Publisher> Publishers { get; set; }
+        public virtual DbSet<Rating> Ratings { get; set; }
+        public virtual DbSet<Series> Series { get; set; }
+        public virtual DbSet<Tag> Tags { get; set; }
+
+        #endregion
+
+        private readonly string ConnectionString;
+
+        [Obsolete]
+        public CalibreContext()
+        {
+        }
+
+        /// <summary>
+        /// </summary>
+        /// <param name="connectionString">Filename=D:\\metadata.db</param>
+        public CalibreContext(string connectionString)
+        {
+            ConnectionString = connectionString;
+        }
+
+        public CalibreContext(DbContextOptions<CalibreContext> options)
+            : base(options)
+        {
+        }
+
+
+        #region
+
+        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+        {
+            if (!optionsBuilder.IsConfigured)
+            {
+                optionsBuilder
+                    .UseSqlite(ConnectionString);
+            }
+        }
+
+        protected override void OnModelCreating(ModelBuilder modelBuilder)
+        {
+            modelBuilder.Entity<Annotation>(entity =>
+            {
+                entity.ToTable("annotations");
+
+                entity.HasIndex(e => new { e.Book, e.UserType, e.User, e.Format, e.AnnotType, e.AnnotId }, "IX_annotations_book_user_type_user_format_annot_type_annot_id")
+                    .IsUnique();
+
+                entity.HasIndex(e => e.Book, "annot_idx");
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.AnnotData)
+                    .IsRequired()
+                    .HasColumnName("annot_data");
+
+                entity.Property(e => e.AnnotId)
+                    .IsRequired()
+                    .HasColumnName("annot_id");
+
+                entity.Property(e => e.AnnotType)
+                    .IsRequired()
+                    .HasColumnName("annot_type");
+
+                entity.Property(e => e.Book).HasColumnName("book");
+
+                entity.Property(e => e.Format)
+                    .IsRequired()
+                    .HasColumnName("format");
+
+                entity.Property(e => e.SearchableText)
+                    .IsRequired()
+                    .HasColumnName("searchable_text")
+                    .HasDefaultValueSql("\"\"");
+
+                entity.Property(e => e.Timestamp).HasColumnName("timestamp");
+
+                entity.Property(e => e.User)
+                    .IsRequired()
+                    .HasColumnName("user");
+
+                entity.Property(e => e.UserType)
+                    .IsRequired()
+                    .HasColumnName("user_type");
+            });
+
+            modelBuilder.Entity<AnnotationsDirtied>(entity =>
+            {
+                entity.ToTable("annotations_dirtied");
+
+                entity.HasIndex(e => e.Book, "IX_annotations_dirtied_book")
+                    .IsUnique();
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Book).HasColumnName("book");
+            });
+
+            modelBuilder.Entity<AnnotationsFt>(entity =>
+            {
+                entity.HasNoKey();
+
+                entity.ToTable("annotations_fts");
+
+                entity.Property(e => e.SearchableText).HasColumnName("searchable_text");
+            });
+
+            modelBuilder.Entity<AnnotationsFtsConfig>(entity =>
+            {
+                entity.HasKey(e => e.K);
+
+                entity.ToTable("annotations_fts_config");
+
+                entity.Property(e => e.K).HasColumnName("k");
+
+                entity.Property(e => e.V).HasColumnName("v");
+            });
+
+            modelBuilder.Entity<AnnotationsFtsDatum>(entity =>
+            {
+                entity.ToTable("annotations_fts_data");
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Block).HasColumnName("block");
+            });
+
+            modelBuilder.Entity<AnnotationsFtsDocsize>(entity =>
+            {
+                entity.ToTable("annotations_fts_docsize");
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Sz).HasColumnName("sz");
+            });
+
+            modelBuilder.Entity<AnnotationsFtsIdx>(entity =>
+            {
+                entity.HasKey(e => new { e.Segid, e.Term });
+
+                entity.ToTable("annotations_fts_idx");
+
+                entity.Property(e => e.Segid).HasColumnName("segid");
+
+                entity.Property(e => e.Term).HasColumnName("term");
+
+                entity.Property(e => e.Pgno).HasColumnName("pgno");
+            });
+
+            modelBuilder.Entity<AnnotationsFtsStemmed>(entity =>
+            {
+                entity.HasNoKey();
+
+                entity.ToTable("annotations_fts_stemmed");
+
+                entity.Property(e => e.SearchableText).HasColumnName("searchable_text");
+            });
+
+            modelBuilder.Entity<AnnotationsFtsStemmedConfig>(entity =>
+            {
+                entity.HasKey(e => e.K);
+
+                entity.ToTable("annotations_fts_stemmed_config");
+
+                entity.Property(e => e.K).HasColumnName("k");
+
+                entity.Property(e => e.V).HasColumnName("v");
+            });
+
+            modelBuilder.Entity<AnnotationsFtsStemmedDatum>(entity =>
+            {
+                entity.ToTable("annotations_fts_stemmed_data");
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Block).HasColumnName("block");
+            });
+
+            modelBuilder.Entity<AnnotationsFtsStemmedDocsize>(entity =>
+            {
+                entity.ToTable("annotations_fts_stemmed_docsize");
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Sz).HasColumnName("sz");
+            });
+
+            modelBuilder.Entity<AnnotationsFtsStemmedIdx>(entity =>
+            {
+                entity.HasKey(e => new { e.Segid, e.Term });
+
+                entity.ToTable("annotations_fts_stemmed_idx");
+
+                entity.Property(e => e.Segid).HasColumnName("segid");
+
+                entity.Property(e => e.Term).HasColumnName("term");
+
+                entity.Property(e => e.Pgno).HasColumnName("pgno");
+            });
+
+            modelBuilder.Entity<Author>(entity =>
+            {
+                entity.ToTable("authors");
+
+                entity.HasIndex(e => e.Name, "IX_authors_name")
+                    .IsUnique();
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Link)
+                    .IsRequired()
+                    .HasColumnName("link")
+                    .HasDefaultValueSql("\"\"");
+
+                entity.Property(e => e.Name)
+                    .IsRequired()
+                    .HasColumnName("name");
+
+                entity.Property(e => e.Sort).HasColumnName("sort");
+            });
+
+            modelBuilder.Entity<Book>(entity =>
+            {
+                entity.ToTable("books");
+
+                entity.HasIndex(e => e.AuthorSort, "authors_idx");
+
+                entity.HasIndex(e => e.Sort, "books_idx");
+
+                entity.Property(e => e.Id).HasColumnName("id");
+
+                entity.Property(e => e.AuthorSort).HasColumnName("author_sort");
+
+                entity.Property(e => e.Flags)
+                    .HasColumnName("flags")
+                    .HasDefaultValueSql("1");
+
+                entity.Property(e => e.HasCover)
+                    .HasColumnType("BOOL")
+                    .HasColumnName("has_cover")
+                    .HasDefaultValueSql("0");
+
+                entity.Property(e => e.Isbn)
+                    .HasColumnName("isbn")
+                    .HasDefaultValueSql("\"\"");
+
+                entity.Property(e => e.LastModified)
+                    .IsRequired()
+                    .HasColumnType("TIMESTAMP")
+                    .HasColumnName("last_modified")
+                    .HasDefaultValueSql("\"2000-01-01 00:00:00+00:00\"");
+
+                entity.Property(e => e.Lccn)
+                    .HasColumnName("lccn")
+                    .HasDefaultValueSql("\"\"");
+
+                entity.Property(e => e.Path)
+                    .IsRequired()
+                    .HasColumnName("path")
+                    .HasDefaultValueSql("\"\"");
+
+                entity.Property(e => e.Pubdate)
+                    .HasColumnType("TIMESTAMP")
+                    .HasColumnName("pubdate")
+                    .HasDefaultValueSql("CURRENT_TIMESTAMP");
+
+                entity.Property(e => e.SeriesIndex)
+                    .HasColumnName("series_index")
+                    .HasDefaultValueSql("1.0");
+
+                entity.Property(e => e.Sort).HasColumnName("sort");
+
+                entity.Property(e => e.Timestamp)
+                    .HasColumnType("TIMESTAMP")
+                    .HasColumnName("timestamp")
+                    .HasDefaultValueSql("CURRENT_TIMESTAMP");
+
+                entity.Property(e => e.Title)
+                    .IsRequired()
+                    .HasColumnName("title")
+                    .HasDefaultValueSql("'Unknown'");
+
+                entity.Property(e => e.Uuid).HasColumnName("uuid");
+            });
+
+            modelBuilder.Entity<BooksAuthorsLink>(entity =>
+            {
+                entity.ToTable("books_authors_link");
+
+                entity.HasIndex(e => new { e.Book, e.Author }, "IX_books_authors_link_book_author")
+                    .IsUnique();
+
+                entity.HasIndex(e => e.Author, "books_authors_link_aidx");
+
+                entity.HasIndex(e => e.Book, "books_authors_link_bidx");
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Author).HasColumnName("author");
+
+                entity.Property(e => e.Book).HasColumnName("book");
+            });
+
+            modelBuilder.Entity<BooksLanguagesLink>(entity =>
+            {
+                entity.ToTable("books_languages_link");
+
+                entity.HasIndex(e => new { e.Book, e.LangCode }, "IX_books_languages_link_book_lang_code")
+                    .IsUnique();
+
+                entity.HasIndex(e => e.LangCode, "books_languages_link_aidx");
+
+                entity.HasIndex(e => e.Book, "books_languages_link_bidx");
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Book).HasColumnName("book");
+
+                entity.Property(e => e.ItemOrder).HasColumnName("item_order");
+
+                entity.Property(e => e.LangCode).HasColumnName("lang_code");
+            });
+
+            modelBuilder.Entity<BooksPluginDatum>(entity =>
+            {
+                entity.ToTable("books_plugin_data");
+
+                entity.HasIndex(e => new { e.Book, e.Name }, "IX_books_plugin_data_book_name")
+                    .IsUnique();
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Book).HasColumnName("book");
+
+                entity.Property(e => e.Name)
+                    .IsRequired()
+                    .HasColumnName("name");
+
+                entity.Property(e => e.Val)
+                    .IsRequired()
+                    .HasColumnName("val");
+            });
+
+            modelBuilder.Entity<BooksPublishersLink>(entity =>
+            {
+                entity.ToTable("books_publishers_link");
+
+                entity.HasIndex(e => e.Book, "IX_books_publishers_link_book")
+                    .IsUnique();
+
+                entity.HasIndex(e => e.Publisher, "books_publishers_link_aidx");
+
+                entity.HasIndex(e => e.Book, "books_publishers_link_bidx");
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Book).HasColumnName("book");
+
+                entity.Property(e => e.Publisher).HasColumnName("publisher");
+            });
+
+            modelBuilder.Entity<BooksRatingsLink>(entity =>
+            {
+                entity.ToTable("books_ratings_link");
+
+                entity.HasIndex(e => new { e.Book, e.Rating }, "IX_books_ratings_link_book_rating")
+                    .IsUnique();
+
+                entity.HasIndex(e => e.Rating, "books_ratings_link_aidx");
+
+                entity.HasIndex(e => e.Book, "books_ratings_link_bidx");
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Book).HasColumnName("book");
+
+                entity.Property(e => e.Rating).HasColumnName("rating");
+            });
+
+            modelBuilder.Entity<BooksSeriesLink>(entity =>
+            {
+                entity.ToTable("books_series_link");
+
+                entity.HasIndex(e => e.Book, "IX_books_series_link_book")
+                    .IsUnique();
+
+                entity.HasIndex(e => e.Series, "books_series_link_aidx");
+
+                entity.HasIndex(e => e.Book, "books_series_link_bidx");
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Book).HasColumnName("book");
+
+                entity.Property(e => e.Series).HasColumnName("series");
+            });
+
+            modelBuilder.Entity<BooksTagsLink>(entity =>
+            {
+                entity.ToTable("books_tags_link");
+
+                entity.HasIndex(e => new { e.Book, e.Tag }, "IX_books_tags_link_book_tag")
+                    .IsUnique();
+
+                entity.HasIndex(e => e.Tag, "books_tags_link_aidx");
+
+                entity.HasIndex(e => e.Book, "books_tags_link_bidx");
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Book).HasColumnName("book");
+
+                entity.Property(e => e.Tag).HasColumnName("tag");
+            });
+
+            modelBuilder.Entity<Comment>(entity =>
+            {
+                entity.ToTable("comments");
+
+                entity.HasIndex(e => e.Book, "IX_comments_book")
+                    .IsUnique();
+
+                entity.HasIndex(e => e.Book, "comments_idx");
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Book).HasColumnName("book");
+
+                entity.Property(e => e.Text)
+                    .IsRequired()
+                    .HasColumnName("text");
+            });
+
+            modelBuilder.Entity<ConversionOption>(entity =>
+            {
+                entity.ToTable("conversion_options");
+
+                entity.HasIndex(e => new { e.Format, e.Book }, "IX_conversion_options_format_book")
+                    .IsUnique();
+
+                entity.HasIndex(e => e.Format, "conversion_options_idx_a");
+
+                entity.HasIndex(e => e.Book, "conversion_options_idx_b");
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Book).HasColumnName("book");
+
+                entity.Property(e => e.Data)
+                    .IsRequired()
+                    .HasColumnName("data");
+
+                entity.Property(e => e.Format)
+                    .IsRequired()
+                    .HasColumnName("format");
+            });
+
+            modelBuilder.Entity<CustomColumn>(entity =>
+            {
+                entity.ToTable("custom_columns");
+
+                entity.HasIndex(e => e.Label, "IX_custom_columns_label")
+                    .IsUnique();
+
+                entity.HasIndex(e => e.Label, "custom_columns_idx");
+
+                entity.Property(e => e.Id).HasColumnName("id");
+
+                entity.Property(e => e.Datatype)
+                    .IsRequired()
+                    .HasColumnName("datatype");
+
+                entity.Property(e => e.Display)
+                    .IsRequired()
+                    .HasColumnName("display")
+                    .HasDefaultValueSql("\"{}\"");
+
+                entity.Property(e => e.Editable)
+                    .IsRequired()
+                    .HasColumnType("BOOL")
+                    .HasColumnName("editable")
+                    .HasDefaultValueSql("1");
+
+                entity.Property(e => e.IsMultiple)
+                    .IsRequired()
+                    .HasColumnType("BOOL")
+                    .HasColumnName("is_multiple")
+                    .HasDefaultValueSql("0");
+
+                entity.Property(e => e.Label)
+                    .IsRequired()
+                    .HasColumnName("label");
+
+                entity.Property(e => e.MarkForDelete)
+                    .IsRequired()
+                    .HasColumnType("BOOL")
+                    .HasColumnName("mark_for_delete")
+                    .HasDefaultValueSql("0");
+
+                entity.Property(e => e.Name)
+                    .IsRequired()
+                    .HasColumnName("name");
+
+                entity.Property(e => e.Normalized)
+                    .IsRequired()
+                    .HasColumnType("BOOL")
+                    .HasColumnName("normalized");
+            });
+
+            modelBuilder.Entity<Datum>(entity =>
+            {
+                entity.ToTable("data");
+
+                entity.HasIndex(e => new { e.Book, e.Format }, "IX_data_book_format")
+                    .IsUnique();
+
+                entity.HasIndex(e => e.Book, "data_idx");
+
+                entity.HasIndex(e => e.Format, "formats_idx");
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Book).HasColumnName("book");
+
+                entity.Property(e => e.Format)
+                    .IsRequired()
+                    .HasColumnName("format");
+
+                entity.Property(e => e.Name)
+                    .IsRequired()
+                    .HasColumnName("name");
+
+                entity.Property(e => e.UncompressedSize).HasColumnName("uncompressed_size");
+            });
+
+            modelBuilder.Entity<Feed>(entity =>
+            {
+                entity.ToTable("feeds");
+
+                entity.HasIndex(e => e.Title, "IX_feeds_title")
+                    .IsUnique();
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Script)
+                    .IsRequired()
+                    .HasColumnName("script");
+
+                entity.Property(e => e.Title)
+                    .IsRequired()
+                    .HasColumnName("title");
+            });
+
+            modelBuilder.Entity<Identifier>(entity =>
+            {
+                entity.ToTable("identifiers");
+
+                entity.HasIndex(e => new { e.Book, e.Type }, "IX_identifiers_book_type")
+                    .IsUnique();
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Book).HasColumnName("book");
+
+                entity.Property(e => e.Type)
+                    .IsRequired()
+                    .HasColumnName("type")
+                    .HasDefaultValueSql("\"isbn\"");
+
+                entity.Property(e => e.Val)
+                    .IsRequired()
+                    .HasColumnName("val");
+            });
+
+            modelBuilder.Entity<Language>(entity =>
+            {
+                entity.ToTable("languages");
+
+                entity.HasIndex(e => e.LangCode, "IX_languages_lang_code")
+                    .IsUnique();
+
+                entity.HasIndex(e => e.LangCode, "languages_idx");
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.LangCode)
+                    .IsRequired()
+                    .HasColumnName("lang_code");
+            });
+
+            modelBuilder.Entity<LastReadPosition>(entity =>
+            {
+                entity.ToTable("last_read_positions");
+
+                entity.HasIndex(e => new { e.User, e.Device, e.Book, e.Format }, "IX_last_read_positions_user_device_book_format")
+                    .IsUnique();
+
+                entity.HasIndex(e => e.Book, "lrp_idx");
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Book).HasColumnName("book");
+
+                entity.Property(e => e.Cfi)
+                    .IsRequired()
+                    .HasColumnName("cfi");
+
+                entity.Property(e => e.Device)
+                    .IsRequired()
+                    .HasColumnName("device");
+
+                entity.Property(e => e.Epoch).HasColumnName("epoch");
+
+                entity.Property(e => e.Format)
+                    .IsRequired()
+                    .HasColumnName("format");
+
+                entity.Property(e => e.PosFrac).HasColumnName("pos_frac");
+
+                entity.Property(e => e.User)
+                    .IsRequired()
+                    .HasColumnName("user");
+            });
+
+            modelBuilder.Entity<LibraryId>(entity =>
+            {
+                entity.ToTable("library_id");
+
+                entity.HasIndex(e => e.Uuid, "IX_library_id_uuid")
+                    .IsUnique();
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Uuid)
+                    .IsRequired()
+                    .HasColumnName("uuid");
+            });
+
+            modelBuilder.Entity<MetadataDirtied>(entity =>
+            {
+                entity.ToTable("metadata_dirtied");
+
+                entity.HasIndex(e => e.Book, "IX_metadata_dirtied_book")
+                    .IsUnique();
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Book).HasColumnName("book");
+            });
+
+            modelBuilder.Entity<Preference>(entity =>
+            {
+                entity.ToTable("preferences");
+
+                entity.HasIndex(e => e.Key, "IX_preferences_key")
+                    .IsUnique();
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Key)
+                    .IsRequired()
+                    .HasColumnName("key");
+
+                entity.Property(e => e.Val)
+                    .IsRequired()
+                    .HasColumnName("val");
+            });
+
+            modelBuilder.Entity<Publisher>(entity =>
+            {
+                entity.ToTable("publishers");
+
+                entity.HasIndex(e => e.Name, "IX_publishers_name")
+                    .IsUnique();
+
+                entity.HasIndex(e => e.Name, "publishers_idx");
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Name)
+                    .IsRequired()
+                    .HasColumnName("name");
+
+                entity.Property(e => e.Sort).HasColumnName("sort");
+            });
+
+            modelBuilder.Entity<Rating>(entity =>
+            {
+                entity.ToTable("ratings");
+
+                entity.HasIndex(e => e.Rating1, "IX_ratings_rating")
+                    .IsUnique();
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Rating1).HasColumnName("rating");
+            });
+
+            modelBuilder.Entity<Series>(entity =>
+            {
+                entity.ToTable("series");
+
+                entity.HasIndex(e => e.Name, "IX_series_name")
+                    .IsUnique();
+
+                entity.HasIndex(e => e.Name, "series_idx");
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Name)
+                    .IsRequired()
+                    .HasColumnName("name");
+
+                entity.Property(e => e.Sort).HasColumnName("sort");
+            });
+
+            modelBuilder.Entity<Tag>(entity =>
+            {
+                entity.ToTable("tags");
+
+                entity.HasIndex(e => e.Name, "IX_tags_name")
+                    .IsUnique();
+
+                entity.HasIndex(e => e.Name, "tags_idx");
+
+                entity.Property(e => e.Id)
+                    .ValueGeneratedNever()
+                    .HasColumnName("id");
+
+                entity.Property(e => e.Name)
+                    .IsRequired()
+                    .HasColumnName("name");
+            });
+
+            OnModelCreatingPartial(modelBuilder);
+        }
+
+        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
+
+        #endregion
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/Annotation.cs b/src/Calibre.Model.Database/Entities/Annotation.cs
new file mode 100644
index 0000000..a93d9e1
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/Annotation.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class Annotation
+    {
+        public long Id { get; set; }
+        public long Book { get; set; }
+        public string Format { get; set; }
+        public string UserType { get; set; }
+        public string User { get; set; }
+        public double Timestamp { get; set; }
+        public string AnnotId { get; set; }
+        public string AnnotType { get; set; }
+        public string AnnotData { get; set; }
+        public string SearchableText { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/AnnotationsDirtied.cs b/src/Calibre.Model.Database/Entities/AnnotationsDirtied.cs
new file mode 100644
index 0000000..d0103ac
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/AnnotationsDirtied.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class AnnotationsDirtied
+    {
+        public long Id { get; set; }
+        public long Book { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/AnnotationsFt.cs b/src/Calibre.Model.Database/Entities/AnnotationsFt.cs
new file mode 100644
index 0000000..dd01b0d
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/AnnotationsFt.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class AnnotationsFt
+    {
+        public byte[] SearchableText { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/AnnotationsFtsConfig.cs b/src/Calibre.Model.Database/Entities/AnnotationsFtsConfig.cs
new file mode 100644
index 0000000..c4ae969
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/AnnotationsFtsConfig.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class AnnotationsFtsConfig
+    {
+        public byte[] K { get; set; }
+        public byte[] V { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/AnnotationsFtsDatum.cs b/src/Calibre.Model.Database/Entities/AnnotationsFtsDatum.cs
new file mode 100644
index 0000000..25eace9
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/AnnotationsFtsDatum.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class AnnotationsFtsDatum
+    {
+        public long Id { get; set; }
+        public byte[] Block { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/AnnotationsFtsDocsize.cs b/src/Calibre.Model.Database/Entities/AnnotationsFtsDocsize.cs
new file mode 100644
index 0000000..cf30bb6
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/AnnotationsFtsDocsize.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class AnnotationsFtsDocsize
+    {
+        public long Id { get; set; }
+        public byte[] Sz { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/AnnotationsFtsIdx.cs b/src/Calibre.Model.Database/Entities/AnnotationsFtsIdx.cs
new file mode 100644
index 0000000..949c334
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/AnnotationsFtsIdx.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class AnnotationsFtsIdx
+    {
+        public byte[] Segid { get; set; }
+        public byte[] Term { get; set; }
+        public byte[] Pgno { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/AnnotationsFtsStemmed.cs b/src/Calibre.Model.Database/Entities/AnnotationsFtsStemmed.cs
new file mode 100644
index 0000000..df4170e
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/AnnotationsFtsStemmed.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class AnnotationsFtsStemmed
+    {
+        public byte[] SearchableText { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/AnnotationsFtsStemmedConfig.cs b/src/Calibre.Model.Database/Entities/AnnotationsFtsStemmedConfig.cs
new file mode 100644
index 0000000..b2811ea
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/AnnotationsFtsStemmedConfig.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class AnnotationsFtsStemmedConfig
+    {
+        public byte[] K { get; set; }
+        public byte[] V { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/AnnotationsFtsStemmedDatum.cs b/src/Calibre.Model.Database/Entities/AnnotationsFtsStemmedDatum.cs
new file mode 100644
index 0000000..0d551f4
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/AnnotationsFtsStemmedDatum.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class AnnotationsFtsStemmedDatum
+    {
+        public long Id { get; set; }
+        public byte[] Block { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/AnnotationsFtsStemmedDocsize.cs b/src/Calibre.Model.Database/Entities/AnnotationsFtsStemmedDocsize.cs
new file mode 100644
index 0000000..64d7c7d
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/AnnotationsFtsStemmedDocsize.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class AnnotationsFtsStemmedDocsize
+    {
+        public long Id { get; set; }
+        public byte[] Sz { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/AnnotationsFtsStemmedIdx.cs b/src/Calibre.Model.Database/Entities/AnnotationsFtsStemmedIdx.cs
new file mode 100644
index 0000000..cb13f5a
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/AnnotationsFtsStemmedIdx.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class AnnotationsFtsStemmedIdx
+    {
+        public byte[] Segid { get; set; }
+        public byte[] Term { get; set; }
+        public byte[] Pgno { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/Author.cs b/src/Calibre.Model.Database/Entities/Author.cs
new file mode 100644
index 0000000..b3c04f0
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/Author.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class Author
+    {
+        public long Id { get; set; }
+        public string Name { get; set; }
+        public string Sort { get; set; }
+        public string Link { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/Book.cs b/src/Calibre.Model.Database/Entities/Book.cs
new file mode 100644
index 0000000..c6613b2
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/Book.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class Book
+    {
+        public long Id { get; set; }
+        public string Title { get; set; }
+        public string Sort { get; set; }
+        public byte[] Timestamp { get; set; }
+        public byte[] Pubdate { get; set; }
+        public double SeriesIndex { get; set; }
+        public string AuthorSort { get; set; }
+        public string Isbn { get; set; }
+        public string Lccn { get; set; }
+        public string Path { get; set; }
+        public long Flags { get; set; }
+        public string Uuid { get; set; }
+        public byte[] HasCover { get; set; }
+        public byte[] LastModified { get; set; }
+
+
+        public override string ToString()
+        {
+            return $"{Id}.{Title}";
+        }
+    }
+};
diff --git a/src/Calibre.Model.Database/Entities/BooksAuthorsLink.cs b/src/Calibre.Model.Database/Entities/BooksAuthorsLink.cs
new file mode 100644
index 0000000..b420527
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/BooksAuthorsLink.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class BooksAuthorsLink
+    {
+        public long Id { get; set; }
+        public long Book { get; set; }
+        public long Author { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/BooksLanguagesLink.cs b/src/Calibre.Model.Database/Entities/BooksLanguagesLink.cs
new file mode 100644
index 0000000..268b52e
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/BooksLanguagesLink.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class BooksLanguagesLink
+    {
+        public long Id { get; set; }
+        public long Book { get; set; }
+        public long LangCode { get; set; }
+        public long ItemOrder { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/BooksPluginDatum.cs b/src/Calibre.Model.Database/Entities/BooksPluginDatum.cs
new file mode 100644
index 0000000..9427273
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/BooksPluginDatum.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class BooksPluginDatum
+    {
+        public long Id { get; set; }
+        public long Book { get; set; }
+        public string Name { get; set; }
+        public string Val { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/BooksPublishersLink.cs b/src/Calibre.Model.Database/Entities/BooksPublishersLink.cs
new file mode 100644
index 0000000..e691918
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/BooksPublishersLink.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class BooksPublishersLink
+    {
+        public long Id { get; set; }
+        public long Book { get; set; }
+        public long Publisher { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/BooksRatingsLink.cs b/src/Calibre.Model.Database/Entities/BooksRatingsLink.cs
new file mode 100644
index 0000000..7319c90
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/BooksRatingsLink.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class BooksRatingsLink
+    {
+        public long Id { get; set; }
+        public long Book { get; set; }
+        public long Rating { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/BooksSeriesLink.cs b/src/Calibre.Model.Database/Entities/BooksSeriesLink.cs
new file mode 100644
index 0000000..0aec5ba
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/BooksSeriesLink.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class BooksSeriesLink
+    {
+        public long Id { get; set; }
+        public long Book { get; set; }
+        public long Series { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/BooksTagsLink.cs b/src/Calibre.Model.Database/Entities/BooksTagsLink.cs
new file mode 100644
index 0000000..7ca2060
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/BooksTagsLink.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class BooksTagsLink
+    {
+        public long Id { get; set; }
+        public long Book { get; set; }
+        public long Tag { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/Comment.cs b/src/Calibre.Model.Database/Entities/Comment.cs
new file mode 100644
index 0000000..7e26c5e
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/Comment.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class Comment
+    {
+        public long Id { get; set; }
+        public long Book { get; set; }
+        public string Text { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/ConversionOption.cs b/src/Calibre.Model.Database/Entities/ConversionOption.cs
new file mode 100644
index 0000000..f3330c9
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/ConversionOption.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class ConversionOption
+    {
+        public long Id { get; set; }
+        public string Format { get; set; }
+        public long? Book { get; set; }
+        public byte[] Data { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/CustomColumn.cs b/src/Calibre.Model.Database/Entities/CustomColumn.cs
new file mode 100644
index 0000000..fef3fcb
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/CustomColumn.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class CustomColumn
+    {
+        public long Id { get; set; }
+        public string Label { get; set; }
+        public string Name { get; set; }
+        public string Datatype { get; set; }
+        public byte[] MarkForDelete { get; set; }
+        public byte[] Editable { get; set; }
+        public string Display { get; set; }
+        public byte[] IsMultiple { get; set; }
+        public byte[] Normalized { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/Datum.cs b/src/Calibre.Model.Database/Entities/Datum.cs
new file mode 100644
index 0000000..4c75566
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/Datum.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class Datum
+    {
+        public long Id { get; set; }
+        public long Book { get; set; }
+        public string Format { get; set; }
+        public long UncompressedSize { get; set; }
+        public string Name { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/Feed.cs b/src/Calibre.Model.Database/Entities/Feed.cs
new file mode 100644
index 0000000..7e9e569
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/Feed.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class Feed
+    {
+        public long Id { get; set; }
+        public string Title { get; set; }
+        public string Script { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/Identifier.cs b/src/Calibre.Model.Database/Entities/Identifier.cs
new file mode 100644
index 0000000..426b7c2
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/Identifier.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class Identifier
+    {
+        public long Id { get; set; }
+        public long Book { get; set; }
+        public string Type { get; set; }
+        public string Val { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/Language.cs b/src/Calibre.Model.Database/Entities/Language.cs
new file mode 100644
index 0000000..600c035
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/Language.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class Language
+    {
+        public long Id { get; set; }
+        public string LangCode { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/LastReadPosition.cs b/src/Calibre.Model.Database/Entities/LastReadPosition.cs
new file mode 100644
index 0000000..f115aa8
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/LastReadPosition.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class LastReadPosition
+    {
+        public long Id { get; set; }
+        public long Book { get; set; }
+        public string Format { get; set; }
+        public string User { get; set; }
+        public string Device { get; set; }
+        public string Cfi { get; set; }
+        public double Epoch { get; set; }
+        public double PosFrac { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/LibraryId.cs b/src/Calibre.Model.Database/Entities/LibraryId.cs
new file mode 100644
index 0000000..a10376a
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/LibraryId.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class LibraryId
+    {
+        public long Id { get; set; }
+        public string Uuid { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/MetadataDirtied.cs b/src/Calibre.Model.Database/Entities/MetadataDirtied.cs
new file mode 100644
index 0000000..21b46db
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/MetadataDirtied.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class MetadataDirtied
+    {
+        public long Id { get; set; }
+        public long Book { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/Preference.cs b/src/Calibre.Model.Database/Entities/Preference.cs
new file mode 100644
index 0000000..527fd32
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/Preference.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class Preference
+    {
+        public long Id { get; set; }
+        public string Key { get; set; }
+        public string Val { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/Publisher.cs b/src/Calibre.Model.Database/Entities/Publisher.cs
new file mode 100644
index 0000000..afdae2b
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/Publisher.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class Publisher
+    {
+        public long Id { get; set; }
+        public string Name { get; set; }
+        public string Sort { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/Rating.cs b/src/Calibre.Model.Database/Entities/Rating.cs
new file mode 100644
index 0000000..edc93df
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/Rating.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class Rating
+    {
+        public long Id { get; set; }
+        public long? Rating1 { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/Series.cs b/src/Calibre.Model.Database/Entities/Series.cs
new file mode 100644
index 0000000..0cbe0d2
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/Series.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class Series
+    {
+        public long Id { get; set; }
+        public string Name { get; set; }
+        public string Sort { get; set; }
+    }
+}
diff --git a/src/Calibre.Model.Database/Entities/Tag.cs b/src/Calibre.Model.Database/Entities/Tag.cs
new file mode 100644
index 0000000..4363e73
--- /dev/null
+++ b/src/Calibre.Model.Database/Entities/Tag.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+
+#nullable disable
+
+namespace Calibre.Model.Database.Entities
+{
+    public partial class Tag
+    {
+        public long Id { get; set; }
+        public string Name { get; set; }
+    }
+}

src/Calibre.sln 39(+39 -0)

diff --git a/src/Calibre.sln b/src/Calibre.sln
new file mode 100644
index 0000000..d65cffe
--- /dev/null
+++ b/src/Calibre.sln
@@ -0,0 +1,39 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31727.386
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Calibre", "Calibre\Calibre.csproj", "{39E1440C-9955-4744-8A22-02ED52502C11}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Calibre.Model.Database", "Calibre.Model.Database\Calibre.Model.Database.csproj", "{4AA0EAB2-7B70-495A-9769-1665B857A91B}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Model", "Model", "{951387AC-1771-4B72-B885-B5DFAFB55D4D}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{5654144E-E0B3-4C6D-AFEB-799E77215B4E}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{39E1440C-9955-4744-8A22-02ED52502C11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{39E1440C-9955-4744-8A22-02ED52502C11}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{39E1440C-9955-4744-8A22-02ED52502C11}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{39E1440C-9955-4744-8A22-02ED52502C11}.Release|Any CPU.Build.0 = Release|Any CPU
+		{4AA0EAB2-7B70-495A-9769-1665B857A91B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{4AA0EAB2-7B70-495A-9769-1665B857A91B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{4AA0EAB2-7B70-495A-9769-1665B857A91B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{4AA0EAB2-7B70-495A-9769-1665B857A91B}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(NestedProjects) = preSolution
+		{39E1440C-9955-4744-8A22-02ED52502C11} = {5654144E-E0B3-4C6D-AFEB-799E77215B4E}
+		{4AA0EAB2-7B70-495A-9769-1665B857A91B} = {951387AC-1771-4B72-B885-B5DFAFB55D4D}
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {362F0FEB-FB13-46F0-825D-15E6F10100D4}
+	EndGlobalSection
+EndGlobal
diff --git a/src/Calibre/Calibre.csproj b/src/Calibre/Calibre.csproj
new file mode 100644
index 0000000..44268a9
--- /dev/null
+++ b/src/Calibre/Calibre.csproj
@@ -0,0 +1,19 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>net5.0</TargetFramework>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.10">
+      <PrivateAssets>all</PrivateAssets>
+      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
+    </PackageReference>
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\Calibre.Model.Database\Calibre.Model.Database.csproj" />
+  </ItemGroup>
+
+</Project>
diff --git a/src/Calibre/Program.cs b/src/Calibre/Program.cs
new file mode 100644
index 0000000..26fefee
--- /dev/null
+++ b/src/Calibre/Program.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Linq;
+
+using Calibre.Model.Database;
+
+namespace Calibre
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            var connectionString = @"";
+
+            using (var context = new CalibreContext(connectionString))
+            {
+                var books = context.Books
+                    .OrderBy(e => e.Id)
+                    .ToArray();
+            }
+        }
+    }
+}