How do you create a foreign key relationship in a SQL Server CE (Compact Edition) Database?

前端 未结 7 812
闹比i
闹比i 2021-02-04 23:44

Visual Studio 2005 doesn\'t provide an interface for creating relationships between tables in a SQL Server CE database (I\'m using version 3.0) and you can\'t open a Compact Edi

7条回答
  •  耶瑟儿~
    2021-02-05 00:38

    Unfortunately there is currently no designer support (unlike for SQL Server 2005) for building relationships between tables in SQL Server CE. To build relationships you need to use SQL commands such as:

    ALTER TABLE Orders
    ADD CONSTRAINT FK_Customer_Order
    FOREIGN KEY (CustomerId) REFERENCES Customers(CustomerId)
    

    If you are doing CE development, i would recomend this FAQ:

    EDIT: In Visual Studio 2008 this is now possible to do in the GUI by right-clicking on your table.

提交回复
热议问题