views:

54

answers:

2

I have a Users table and a profile table. The reason they are separate is because information about the user can be put in before they are registered for the site. The problem I'm running into is that when I set the relationship in Sql Server it wants to create a one to many relationship. I don't see any way to change this.

+1  A: 

This should answer your question: http://stackoverflow.com/questions/1722741/defining-a-one-to-one-relationship-in-sql-server

Zabba
+1  A: 

I assume you're creating it using the ASP.NET Membership? If so, simply add a uniqueidentifier column inside your profiles table, set as primary key and you're good to go. SQL won't allow you to add more than 1 record for that ID.

This article provides exactly what you need http://www.asp.net/security/tutorials/storing-additional-user-information-cs

Marko
This mostly worked for me. I set the UserID in the profile table as the primary key, so the primary keys for both were linked as a relationship. This allowed LINQ to see them as a one to one relationship.
Jhorra
You do not need to use a uniqueidentifier for a 1-1 relationship. Just ensure that the foreign key has a unique index on it.
Quick Joe Smith
Yes but isn't this the proper way storing additional user info for ASP.NET Membership? See http://www.asp.net/security/tutorials/storing-additional-user-information-cs
Marko