Is there a table designer for VS2010 database project? - visual-studio-2010

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.

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:
Create everything with SQL Server Management Studio.
Synchronize it into my database project.
When I need to change something, do it in SQL Server Management Studio.
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.

Related

Updating a SQL Server database using Entity Framework is not pulling in new tables

I created a database in Azure and have it working just fine in my project.
I went to extend it today and discovered I'm unable to "Update database" in the .edmx file.
The new table has a PK.
So I created a very based test table and have the same issues with it. This is the table I created:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TestTable]
(
[Id] NVARCHAR(128) NOT NULL,
[Testcolumn] NVARCHAR(256) NOT NULL
);
GO
CREATE UNIQUE NONCLUSTERED INDEX [UserNameIndex]
ON [dbo].[TestTable]([Testcolumn] ASC);
GO
ALTER TABLE [dbo].[TestTable]
ADD CONSTRAINT [PK_dbo.TestTable] PRIMARY KEY CLUSTERED ([Id] ASC);
So again, after creating the table I go into the .edmx and click on update model from database and the new table(s) do not show up in Visual Studio 2017.
Anyone know what could be wrong?
Update:
it gets even weirder. I created a new model and updated from the database and the tables came down. I still can't update the original model though. I don't want the solution to be deleting the model and re-creating it because down the road that is not going to be a good idea.
I had to completely delete the model and recreate it. That was the only thing that fixed it. Nothing to do with the table configuration at all.
EF requires that your table has s Primary key, and that is not the case.

Adding the alter table sciprts and running on SSDT solution

I have an existing SSDT solution and I want to add up the alter table scripts in the solutions and running on the SSDT solution such that the tables are updated according to the scripts?
Example: if I already have a table student with two columns sid and sname and I have a script which add up new column city to the table How can I do this such that table is updated?
So in your live database you have changed it and you want the change to be in SSDT?
If this is the case, do a schema compare with the project as the destination and database as the source - you can choose what to update and it will update the project instead of the database.

Oracle SQL Developer - using foreign keys

First of, this is a pretty basic question but I cant seem to find a basic tutorial on how to use the software.
If i have a table named COUNTRY with the field region_id
and then another table named REGION with a primary key as region_id.
I want to set the region_id field in COUNTRY table as a foreign key.
Are the following steps correct?
Go to constraints, add a new foreign key.
Select COUNTRY as table
Change local column to region_id
![enter image description here][1]
Am I doing it correctly? if not, where am i going wrong
Yes, This is the correct procedure.
If you want your foreign key to have additional behavior (e.g., ON DELETE CASCADE), you can use the "on delete" drop-down in the wizard.
I cant seem to find a basic tutorial on how to use the software.
Have you looked at the Oracle Learning Library for SQL Developer tutorials?
If you search for: Getting Started with Oracle SQL Developer 4.0 you will find a tutorial that gets you up and running SQL Developer, this tutorial includes how to create Foreign Key Constraints.

Visual Studio Database Pro Partial Projects Constraints Issue

In Visual Studio 2008 Database edition one can use "partial projects" to allow a database to be separated into multiple projects for deployment and maintainability. I have been looking into doing this with our project but hit the following snag:
If you have project that defines some base tables, and then you have a different project that defines a new set of tables that have constraints pointing to the tables in the first project, DBPro seems unable to map this relationship. The specific error is:
"CONSTRAINT has an unresolved reference to Table foo" (where foo is in the original DB).
A more concrete example if you'd like to duplicate for yourself the scenario:
Create a Project called BaseDB.
Define in BaseDB a table called Users with the following DDL:
CREATE TABLE [dbo].[Users] (
UserID INT IDENTITY(1,1) PRIMARY KEY,
UserName NVARCHAR(20) NOT NULL
)
Export BaseDB as a partial project adding the _BaseDB.files file to your project.
Create a Project in the same solution called DerivedDB
Use the Import Partial Project to point to BaseDB, confirming if you like that there's a stub reference in your import files pointing to the Users table in BaseDB.
Define a table in DerivedDB called PowerUsers with the following DDL:
CREATE TABLE [dbo].[PowerUsers] (
PowerUserID INT IDENTITY(1,1) PRIMARY KEY,
UserID INT NOT NULL
)
If you do a "Build" at this point, everything works.
Add a FOREIGN KEY CONSTRAINT in the DerivedDB project from PowerUsers to Users with the following DDL:
ALTER TABLE [dbo].[PowerUsers]
ADD CONSTRAINT [PowerUsers_Users_FK]
FOREIGN KEY (UserID)
REFERENCES [dbo].[Users] (UserID)
Performing the above steps should allow you to see the error I'm talking about.
Questions:
Is there a way to fix constraint references across database projects?
If not, should partial projects then be reserved for series of stored procedures and the base project reserved for all DDL of base tables and constraints?

Maximum number of columns in a LINQ to SQL object?

I have 62 columns in a table under SQL 2005 and LINQ to SQL doesn't handle the updates though the reading would work just fine, I tried re-adding the table to the model, created a new data model but nothing worked, I'm guessing I've hit the maximum number of columns limit on an object, can anyone explain that ?
I suspect there is some issue with an identity or timestamp column (something autogenerated on the SQL server). Make sure that any column that is autogenerated is marked that way in the model. You might also want to look at how it is handling concurrency. If you have triggers that update any values on the row after it is updated (changing values) and it is checking all columns on updates, this would cause the update to fail. Typically I create my tables with a timestamp column -- LINQ2SQL picks this up when I generate the model and uses it alone for concurrency.
Solved, either one of the following two
-I'm using a UniqueIdentifier column that was not set as Primary key
-Set Unique ID primary key, checked the properties of the same column in Server Explorer and it was still not showing as Primary key, refreshed the connection,dropped the same table on the model and voila.
So I assume I made a change to my model some time before, deleted the table from the model and added the same from the Server explorer without refreshing the connection and it never used to work.
Question is, does VS Server Explorer maintain it's own table schema and requires connection refresh everytime a change is made in the database ?
There is no limit to the number of columns LINQ to SQL will handle.
Have you got other tables updating successfully?
What else is different about how you are accessing the table content?

Resources