---
title: "FillSchema and AddWithKey Don't Operate As Promised?"
url: "https://osherove.com/blog/2003/6/29/fillschema-and-addwithkey-dont-operate-as-promised.md"
canonical: "https://osherove.com/blog/2003/6/29/fillschema-and-addwithkey-dont-operate-as-promised.html"
published: "2003-06-29T17:42:00"
updated: "2003-06-29T17:42:00"
tags: [".Net Original"]
author: "Roy Osherove"
description: "uuugh! I've been struggling with this one for a few days now, so after hitting all the relevant newg groups, let's see if anyone has a good answer: Given a DataTable, I need to know all the Other DataTables that have a…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# FillSchema and AddWithKey Don't Operate As Promised?

By Roy Osherove June 29, 2003 In [.Net Original](https://osherove.com/blog/category/net-original)

**Historical article** · Originally published June 29, 2003; technical details may be outdated.

uuugh! I've been struggling with this one for a few days now, so after hitting all the relevant newg groups, let's see if anyone has a good answer:

Given a DataTable, I need to know all the Other DataTables that have a
Relation to this table. Specifically, I want to know all the relations in
which this table is a "Details" table (i.e. has a foreign key constraint).

I've tried using the DataAdapter.FillSchema method, but no luck.
I've also tried setting the DataAdapter.MissingSchemaAction to AddWithKey,
but still no luck.
I've made sure that the table actually has a foreign key in the DB(I'm using
Northwind SQL server).

The only way that works, is by using a completely different feature:
Connection.GetOleDBSchemaTable(), but It seems to me that this should be
possible using the DataAdapter as well. All the references I've read on the subject point to the fact that using each of these 2 methods od the DataAdapter will create those missing relations. :(

**Update:**

Just found out that _FillSchema_ or Fill are not supposed to add Data Relations automatically. _GetOleDBSchema_ is the only way. I'll try to create something generic for use in these situations , though.

## More in .Net Original

[All posts in .Net Original](https://osherove.com/blog/category/net-original)

- Jul 1, 2003

    ### [More about .Net Deep Dive](https://osherove.com/blog/2003/7/1/more-about-net-deep-dive.html)

- Jun 30, 2003

    ### [.Net Deep Dive Recap](https://osherove.com/blog/2003/6/30/net-deep-dive-recap.html)

- Jun 27, 2003

    ### [Quick & Easy ADO.NET Speed Improvements](https://osherove.com/blog/2003/6/27/quick-amp-easy-adonet-speed-improvements.html)

- Jun 22, 2003

    ### [Disabling Connection Pooling](https://osherove.com/blog/2003/6/22/disabling-connection-pooling.html)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
