开发者

Is there a table designer for VS2010 database project?

Am I missing something here? It seems that the only options to create a new table in a database project in VS2010 is:

Create a table object as a file, then create all constraints (defaults) as separate files, then create each index as a separate file, and primary key as a separate file and on and on...

Or

Create the entire table schema using the table designer in SSMS and then use the schema compare tool to create a single monolithic file of SQL statements for each element of the table and copy each block of code to a newly created file in VS.

This question was asked 2 years ago and I'm hoping the answer has changed. Please tell me there's a hidden table designer for the database project in VS2010 开发者_JAVA百科that I have just overlooked.


I'm pretty sure there isn't one!

Can I ask why you need a table designer over creating and modifying creation script files for your new objects? Is there anything that this doesn't give you that a designer would?


I just noticed that VS 11 Beta now includes a designer, although it is rough around the edges (relationships, for example, still need to be typed by hand).


The way I use the database project in VS2010 is:

  1. Create everything with SQL Server Management Studio.
  2. Synchronize it into my database project.
  3. When I need to change something, do it in SQL Server Management Studio.
  4. Use Schema Comparisons to synchronize your database project.


Wow... can't believe no one has taken the time to answer this in all this time. Here's a sample of table creation script with some simple constraints.

    CREATE TABLE [User]
(
    UserID              INT             NOT NULL    IDENTITY (1,1), 
    UserName            NVARCHAR(20)    NOT NULL,
    UserPassword        NVARCHAR(20)    NOT NULL,
    EmailAddress        NVARCHAR(50)    NOT NULL,
    Location            NVARCHAR(100),
    MobileNumber        VARCHAR(10),
    CreatedDate         DATETIME        NOT NULL    
        CONSTRAINT User_CreatedDate_DF  DEFAULT                 (GETDATE()),
        CONSTRAINT User_UserID_PK       PRIMARY KEY CLUSTERED   (UserID),
        CONSTRAINT User_UserName_UQ     UNIQUE                  (UserName),
        CONSTRAINT User_EmailAddress_CK CHECK                   (EmailAddress LIKE '%@%.%'),
        CONSTRAINT User_MobileNumber_CK CHECK                   (MobileNumber LIKE '[2-9][0-9][0-9][2-9][0-9][0-9][0-9][0-9][0-9][0-9]')
)

You can use functions to embed in your check constraints, but again, this is a simplistic exaxmple.


As I commented here, the VS2010 reference states that there exist a Table Designer in this document.

But for some reason, no matter what kind of project I create (Server project 2008/2005, database project 2008/2005) I can't get the Table Designer being shown.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜