Leanpub Header

Skip to main content

FROM TABLE TO TWIN

This book is 99% completeLast updated on 2026-06-30

Two builds, one schema, zero faith required. From Table to Twin walks an industrial digital twin's SQL Server and EF Core backbone by hand and from code, then prints exactly where Database First and Code First disagree — for .NET developers who check every table against a live, running console.

Minimum price

$49.99

$69.99

You pay

Author earns

$

Also available for 2 book credits with a Reader Membership

PDF
About

About

About the Book

Have you ever opened the database behind a system you thought you understood, and found two answers where you expected one? You recognize the tables — Unit, Signal, WorkOrder — but then you hit a folder of EF Core migrations that doesn't quite match the SQL someone else wrote by hand, a DbContext with shadow foreign keys nobody named, and a quiet, nagging question: which one of these is actually telling the truth about my data?

From Table to Twin is written specifically to answer that question.

Unlike most Entity Framework books, which hand you a DbContext on page one and never look back, this book takes a deliberately two-path approach. You build the same industrial schema twice — once by hand in SQL Server, reverse-engineered into C#; once from C# with Code First, generating its own migrations — and then you put the two builds side by side. Where Scaffold-DbContext and Fluent API disagree on naming, shadow keys, and inferred relationships, this book doesn't pick a winner and move on. It prints the disagreement, in a dedicated reconciliation chapter, and shows you which one to trust and when.

Try the Live Software Demo Now!

This book is a hands-on, deeply integrated companion guide to NEXUS-1, the same fully interactive, browser-based digital-twin console used throughout the series — except this volume is the one that finally writes down where all of it actually lives.

No server, no installation, and zero setup required. Open the console, and every schema named in this book, every query quoted, and every row counted can be counted again, live, in your browser:

👉 Play with the Live Console: https://gregory82gr.github.io/Nexus-1-phase-0/

What's Under the Hood? (The Schema Blueprint)

This is not a toy Blog/Post sample database. The companion book walks the literal data backbone of an industrial nuclear-plant digital twin — a schema plausibly past two hundred tables, built to the same standard throughout:

  • One schema, seventeen bounded contexts. Reactor Fleet, Instrumentation, Alarm Management, Digital Twin, Root Cause Analysis, Reinforcement Learning, and the rest — every sector the first three NEXUS-1 volumes already wrote to, finally given a single, coherent home.
  • Two builds, one model. Part 1 authors the database by hand in SQL Server — schemas, keys, indexes, constraints, views — then reverse-engineers it with Scaffold-DbContext. Part 2 rebuilds the identical model from C#: configuration classes, value converters, owned types, and generated migrations.
  • The uniform lookup-table generator. Rather than forty near-identical CREATE TABLE listings, the book teaches one shape, one SQL generator, and one generic IEntityTypeConfiguration<T> — and proves it in an appendix that lists every table the generator actually produced.
  • Advanced relationships, taken seriously. Owned types, table-per-type inheritance for equipment hierarchies, many-to-many joins, alternate keys — modelled the way an industrial schema actually needs them, not the way a tutorial simplifies them.
  • Audit, history, and performance, with evidence. Soft delete with query filters, SQL Server temporal tables, RowVersion concurrency — then indexes measured the honest way, with logical reads and execution plans shown before and after, never asserted from memory.
  • Beyond the ORM. A dedicated appendix on Dapper, SqlBulkCopy, and raw SQL — and the harder discipline of knowing the handful of places in a two-hundred-table schema where EF Core is genuinely the wrong tool.

How Every Chapter Is Structured

To keep sixteen chapters of database design from turning into a wall of DDL, every chapter follows the same five-beat scaffold the NEXUS-1 series has used since Volume I:

  1. What You Already Know: The bridge from engineering instincts you already have — a bounded context is just a SQL schema with a passport; a foreign key is just the passport between them.
  2. The Concept: A clear, prose explanation of the modelling decision, never a checklist of EF Core features for their own sake.
  3. See It in NEXUS-1: Direct guidance on exactly where that table, that index, or that migration is live on your console screen.
  4. Try It: Something to actually run — add a Status row and watch it appear without a redeploy; run a migration twice and watch nothing break.
  5. Honest Boundary: A transparent account of what the model simplifies, defers, or deliberately does not claim — because nothing in this book claims to exist that does not.

👤 Who This Is For

This book assumes you're already fluent in C#, comfortable in .NET, and at home in SQL Server. It does not assume you want a guided tour of Entity Framework's feature list — that is not what this book is. If you've ever inherited a database you didn't trust, scaffolded a model you couldn't quite read, or wondered whether your Code First migrations and your DBA's hand-written schema actually agree with each other, this is the book that walks you through finding out — on a real, running reference you can open and check for yourself.

Author: Grigorios Kyriakos Agathangelidis
Greek name: Γρηγόριος Κυριάκος Αγαθαγγελίδης
Also searchable as: Αγαθαγγελίδης ΓρηγόριοςΑγαθαγγελιδης ΓρηγοριοςGrigorios Agathangelidis.

Share this book

Bundle

Bundles that include this book

Author

About the Author

Grigorios Agathangelidis

My name is Grigorios Agathangelidis, and my professional background is in Electrical Engineering and Software Engineering. Of the four NEXUS-1 Companion volumes, this one sits closest to that background — the others asked me to learn a domain from the outside in; this one is the data-engineering discipline I already work in, applied to the platform the rest of the series built.

NEXUS-1 began as a personal challenge: to explore the nuclear-energy domain as a software engineer, learn its fundamental principles, and apply the disciplines of software architecture, systems engineering, simulation, visualization, and user-interface design to create an integrated educational and analytical platform. The first three volumes — From Grid to Core, From Flood to Cause, and From Trial to Policy — each took apart one running engine of that platform: the plant itself, a root-cause diagnostic system, and an interpretable reinforcement-learning agent. Each of those engines quietly wrote to or read from a database, and none of the three books stopped to show where. From Table to Twin is where I went back and answered that question properly — designing and documenting the single SQL Server and EF Core backbone all three engines actually share.

Throughout the series, I have sought to approach each subject with curiosity, rigor, and respect for the limits of my expertise. Where the first three volumes required me to state plainly that I am not a nuclear physicist or a control-room operator, this volume carries a different kind of honesty requirement: the schema is large — plausibly past two hundred tables — and every claim in it is still held to the same standard the rest of the series uses. Nothing is described that cannot be created, queried, and counted again against the live console.

My broader interest extends beyond any single domain to the challenge of understanding, modeling, and reasoning about complex systems — digital twins, root-cause analysis, verification and validation, retrieval-augmented generation, explainable AI, and decision-support systems for industrial environments. The data backbone this volume documents is the connective tissue underneath all of it: the place where an alarm flood, a causal graph, and a Q-table turn out to have been rows in the same database all along.

This release represents Phase 0 of the NEXUS-1 project: the concept, demonstration, and design stage. The long-term roadmap includes a modern microservices-based architecture built on .NET, Angular, SQL Server, message-driven services, and local AI-assisted analytical capabilities — the schema this book walks is the foundation that roadmap will eventually build on.

Above all, NEXUS-1 reflects a belief that meaningful innovation often begins with curiosity, disciplined learning, and the willingness to explore unfamiliar domains — and, just as often, to bring real expertise back to the part of the system that was always going to need it most.

Author: Grigorios Kyriakos Agathangelidis
Greek name: Γρηγόριος Κυριάκος Αγαθαγγελίδης
Also searchable as: Αγαθαγγελίδης ΓρηγόριοςΑγαθαγγελιδης ΓρηγοριοςGrigorios Agathangelidis.

Contents

Table of Contents

  • Preface
  • 1. The Backbone Behind Three Books
  • 2. Enterprise Database Design
  • 3. Normalization Without Dogma
  • 4. Database First
  • 5. Reverse Engineering
  • 6. Entity Framework Core
  • 7. Code First
  • 8. Fluent API
  • 9. ASP.NET Core Identity
  • 10. Lookup Tables, Taught Once
  • 11. Advanced Relationships
  • 12. Audit and History
  • 13. Where the Two Paths Disagree
  • 14. Performance Without Mystery
  • 15. Industrial Best Practices
  • 16. The Final Architecture
  • Epilogue — From Table to Twin
  • Appendix A — Glossary of Data-Modelling and EF Core Terms
  • Appendix B — The Database-First / Code-First Parity Checklist
  • Appendix C — SQL Schema Definitions (every substantive table)
  • Appendix D — Indexes by Example: Execution Plans and Logical Reads
  • Appendix E — Beyond EF Core: Dapper, Raw SQL, and When to Reach for Them
  • Appendix F — C#/.NET Developer Quickstart
  • Appendix G — The Lookup-Table Generator (templates and conventions)
  • Appendix H — Migrations and Seed-Data Reference
  • Appendix I — References and Further Reading
  • Index

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub