Domain ValuesMakes synchronizing database lookup values and enumerations easier. Features
Getting StartedIn Visual Studio, open a C# or Visual Basic project and open the Add New Item dialog. In the Data section, select the Domain values item template, rename the file to Product.dv and then click Add. A basic file is created from the template using the file name supplied. In the above example, the file is intended to populate the dbo.Product table. After the Data keyword the column names are listed separated by the pipe character and each subsequent line represents one row of data. As more lines or columns are added the table automatically formats to keep the columns aligned. The ProductID column also appears next to the Key keyword and so will be used to determine if a row should be created, updated or deleted. In the solution explorer, just under the newly created Product.dv file is a second file named Product.dv.sql. This contains the sql statement generated from the contents of product.dv. Every time the file is saved the sql file will be updated. To add an enum to the project using the same values, replace the text in Product.dv with the following...
When the file is saved another file will appear. This contains the enumeration code and the language is determined by the project type. Open the Product.dv.cs file to view the enumeration. The enum base type and access modifier can be changed, descriptions can be added to each member and the [Flags] attribute can be added. Using the generated sql file with a database projectAdd a database project and create a product table and a post deployment script as below. Build the solution and then right click the database project and select publish. Add the connection info and click the publish button. Once complete the data from the products.dv file will be in the product table. To keep all the database assets in the database project, use the Copy sql to command in the Product.dv file. The file can be copied to any folder in the solution (the folder must already exist). The copied file will be updated anytime a change is made. |