views:

983

answers:

2

I'm new to Data Generation Plans in Visual Studio, but I googled a bit and can't find the answer to this question. I've made modifications to my schema on the database side (changed the size of an NVARCHAR field) based on data that was generated by a Data Generation Plan (a procedure broke because the field was too large), and now I want to generate new data based on the new schema.

Is there any way to re-import the schema from the database or to keep it live and connected at all times?

I know I can just switch the field size inside of the generation plan, but this is a simple case of something that will be more complicated later on.

+2  A: 

Doesn't the IDE force you to update your data generation plan if your schema changes anyway?

From the MSDN:

When you create a data generation plan in a database project, the plan is based on the database schema of the project. If you create a data generation plan and then the schema of the database project changes, you are prompted to update the plan. This behavior occurs in the following cases:

  • You create a data generation plan in a database project that does not have a schema yet. You then import a schema into the database project.
  • You create a data generation plan in a database project that has a schema, and then the schema changes.

In both cases, you are prompted to update the data generation plan when you open it or when it becomes the active document. If you do not update the data generation plan based on the schema changes, you cannot continue to edit the plan. You can close and reopen the data generation plan to display the prompt again.

More evidence from a blog on this subject:

... the schema of the objects inside the database has to match the table inside the database project.

I guess you could dig into the *.dgen file and do a pre-build step (or something similar) that would ensure it always matches your DB schema. Maybe that would automate things enough.

John at CashCommons
It's based on the database schema of the project, not the database schema inside the database. When you create a database project, VS.NET seems to import a copy of the database schema which is then independent of the actual database. I just want to reimport this schema.
brian
OK, let me see if I understand ... You set up a DGP based on a particular DB with its schema. At this point you have a project schema that (for now) matches your DB schema. Later, you changed your DB schema, but the project schema is not updated with this. It looks like you have two issues: your project schema is now out of date, and your DGP is out of date as well. Even if you were to update (re-import) the project schema, you'd still have to update the DGP yourself from what I understand.
John at CashCommons
Yes, which is fine. It'd be nice if I could re-import the schema and my DGP would only need to be changed for those fields that were changed. Am I asking for too much? Is the answer to create an entirely new DGP?
brian
A: 

Use Schema Compare (File menu: Data > Schema Compare > New Schema Comparison) to synchronize project and database schema. After that if you open Data Generation Plan it should ask you to refresh it.

Marek Tihkan