VS2010数据库项目有表设计器吗?

发布于 2024-09-16 21:08:07 字数 289 浏览 5 评论 0原文

我在这里错过了什么吗?似乎在VS2010中的数据库项目中创建新表的唯一选择是:

将表对象创建为文件,然后将所有约束(默认值)创建为单独的文件,然后将每个索引创建为单独的文件,并创建主键作为一个单独的文件,等等...

或者

使用 SSMS 中的表设计器创建整个表模式,然后使用模式比较工具为表的每个元素创建一个 SQL 语句的整体文件,并复制每个块将代码复制到VS中新建的文件中。

这个问题是两年前提出的,我希望答案有所改变。 请告诉我 VS2010 中的数据库项目有一个隐藏的表设计器,我刚刚忽略了。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

恏ㄋ傷疤忘ㄋ疼 2024-09-23 21:08:08

我很确定没有一个!

我可以问为什么您需要一个表设计器来为新对象创建和修改创建脚本文件吗?有什么东西是设计师不能给你的吗?

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?

以往的大感动 2024-09-23 21:08:08

我刚刚注意到 VS 11 Beta 现在包含了一名设计师,尽管它的边缘还很粗糙(例如,关系仍然需要手动输入)。

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

筱果果 2024-09-23 21:08:08

我在VS2010中使用数据库项目的方式是:

  1. 使用SQL Server Management Studio创建一切。
  2. 将其同步到我的数据库项目中。
  3. 当我需要更改某些内容时,可以在 SQL Server Management Studio 中进行。
  4. 使用架构比较来同步您的数据库项目。

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.
贪了杯 2024-09-23 21:08:08

哇......不敢相信这么长时间以来没有人花时间回答这个问题。这是带有一些简单约束的表创建脚本示例。

    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]')
)

您可以使用函数嵌入检查约束中,但同样,这是一个简单的示例。

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.

明明#如月 2024-09-23 21:08:08

正如我在此处评论的那样,VS2010参考指出存在此文档中的表设计器

但由于某种原因,无论我创建哪种类型的项目(服务器项目 2008/2005、数据库项目 2008/2005),我都无法显示表设计器

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文