I just started working on a .NET project that uses a SQL Server DB. I was given a script that setup the database with all the tables, SPs, etc. but no data.
My initial impulse was to go into the DB and manually type in some dummy data to setup a couple users, etc. just so I can get started using the application. However, every time I try to add a record, foreign key constraints get in the way. Unfortunately I can’t show you the schema, but is there a general strategy I could follow for a situation like this?
If you have FK’s getting in the way, you need to start entering data in all the ‘master’ tables. Then you can enter data into your child or detail tables.
For example, say you have an Orders table and a Customers table, and a FK in place between Orders and Customers. The ‘master table’ would be Customers and the detail table, in this example, would be your Orders table. You’ll probably need to enter a few customers first, so that when you enter an order, you can assign a customer to it, and not get a FK error because there is no customer.
I suspect this example is pretty close to the type of problem you’re running into.