Skip to main content

Create Visual Studio 2010 SQL Server 2008 Database Project

To create the Visual Studio 2010 SQL Database Project, open the Visual Studio (VS) 2010 as a administrator. 
  • Click on File -> New -> Project : In the opened “New Project” window, under installed templates click on Database -> SQL Server and select “SQL Server 2008 Database Project”, select the location and click “OK” button.
  • Open the solution explorer, you will find the database project has been created with the default folders.
  • Expand Schema Objects folder, expand Schemas folder, expand dbo folder and expand Tables folder.
  • Right click on Tables, select Add -> New Item. In the opened New Item window, select Table and enter the name Books, click Add.
  • Double click on added Books.Table.sql script file and include create table script.
  • Right click on Tables, select Add -> New Item. In the opened New Item window, select Primary Key, enter name and click Add. Open the script file and add script to add primary key for the Books table.
  • You can add other scripts under respective folder names like Constraints, Indexes, Triggers etc.
  • Under programmability folder you can add Functions, Stored Procedures, Types, Defaults and Rules scripts.
  • We have added table script and primary key script, now set the SQL server connection string settings.
  • Right click on the project and click on the properties. In the properties page, click on Deploy tab.
  • Set the target database connection, change the Deploy action to create a deployment script and deploy to the database, you can change the other default setting values if you want. 
  • Save the settings and right click on the project and click on Deploy. Check the Output window, the deployment is succeeded or not.
  • Open SQL Server Management Studio, and connect to server localhost. Check the database is created or not. The BookStore database should be created with the table Books.
  • Expand Scripts folder in the project, you will find post and pre deployment scripts. You can include the  post and pre deployment scripts in the Scripts folder.

Popular posts from this blog

WCF Service Exception PlainXmlWriter+MaxSizeExceededException

For a WCF service the exception 'System.ServiceModel.Diagnostics.PlainXmlWriter+MaxSizeExceededException' generally occurs when we switched on logging and tracing.   A message was not logged. Exception: System.InvalidOperationException: There was an error generating the XML document. ---> System.ServiceModel.Diagnostics.PlainXmlWriter+MaxSizeExceededException: Exception of type 'System.ServiceModel.Diagnostics.PlainXmlWriter+MaxSizeExceededException' was thrown.   The reason is that "maxSizeOfMessageToLog" configuration parameter value is set to a value lower than the size of the message to log. < system.serviceModel>   < diagnostics > <!-- log all messages received or sent at the transport or service model levels --> < messageLogging logEntireMessage = " true " logMessagesAtServiceLevel = " true " logMalformedMessages = " true " logMessagesAtTransportLevel = " true "    maxMessa...

ISAPI & CGI Restriction configuration missing in IIS

In windows 7 by default ISAPI & CGI Restrictions are not configured. To enable ISAPI & CGI restrictions, GoTo -> Control Panel -> Programs -> Click on "Windows features on or off -> Expand Internet Information Services - >Expand World Wide Web Services ->Select CGI and ISAPI extensions and Click OK. After enabling, Check in IIS, Open your IIS and the feature will be available. What is ISAPI and CGI restrictions : ISAPI and CGI restrictions are request handlers that allow dynamic content to execute on a server. These restrictions are either CGI files (.exe) or ISAPI extensions (.dll). You can add custom ISAPI or CGI restrictions if the IIS configuration system allows this.

Implementing Parallelism With A SearchResultCollection

Implementing Parallel.ForEach with a SearchResultCollection: The below piece of code helps to check the given user is a part of the given active directory group. To implement Parallel.ForEach with a SearchResultCollection, do the casting with the SearchResult object and covert it into a list. //// Directory Searcher var directorySearcher = new DirectorySearcher(string.Format("(CN={0})", groupName)); //// Find group var searchResultCollection = directorySearcher.FindAll().Cast ().ToList(); Parallel.ForEach(searchResultCollection, searchResult => {  // enumerate members  var resultPropColl = searchResult.Properties;  Parallel.ForEach(resultPropColl["member"].Cast ().ToList(), member =>  {    var memberEntry = new DirectoryEntry("LDAP://" + member);    var userProperties = memberEntry.Properties;    if (GetUserNameFromProperties(userProperties, "sAMAccountName") == userName)    {      return true; ...