Is there a table designer for VS2010 database project?

余生长醉 提交于 2019-12-23 09:32:43

问题


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 that I have just overlooked.


回答1:


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?




回答2:


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).




回答3:


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.



回答4:


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.




回答5:


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.



来源:https://stackoverflow.com/questions/3610316/is-there-a-table-designer-for-vs2010-database-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!