Search code examples
.netado.netstrongly-typed-dataset

Strongly typed datasets and schema changes


I have a project which uses strongly typed datasets.

Let's assume I want to change the database schema of the database used by this application. I have a table named Country and I want to add a new column named "IsADemocracy" (that's an example) of the SQL Server datatype BIT.

Now, how do I update the strongly typed dataset so that I can use this new field in the application?

I've tried adding the column in the Country table on the dataset, gave it the type of boolean and mapped its "Source" property to "IsADemocracy".

I can access the field in the application, give it a value, etc, but the underlying queries made by the table adapter have not been updated to reflect this change. They are as they were before I added this column in the strongly typed dataset. I hoped what I did would be enough but it does not seem to be the case.

Should I regenerate the strongly datasets classes somehow? If so, how and what are the implications?

I could probably delete the Country table in the Dataset designer, and redrop it from the Server Explorer, but I have customer queries on it and I don't want to lose them.

Thanks.


Solution

    1. First, make sure you have a backup

    2. Right click on the .xsd node in Solution Explorer and select "Run Custom tool"

    But be careful with your Custom Queries. They have a tendency to disappear without warning. Not always.

    This is one good reason to fill in those queries form the partial class 'main' file.