Best way to add an FK relationship on a view

  • I have been trying to figure out a good way to make a FK relationship from a view to a table. I know you can't add FK's to views but is there another way to make a relationship to another table?

    A developer wants this FK relationship so Linq will recognize it.

    My view looks like this:

    SELECT Username, Password, UserTypeID, MemberID, CreatedDate, LastLogin, Deactivated

    FROM dbo.Login

    WHERE (UserTypeID IN (5, 6))

    This view is just to show a certain type of users. I want to link the UserTypeID to the UserType table.

    Any ideas? Thanks in advance.

  • Quite frankly I just don't think you can do it..


  • Agreed. All RI constraints need to be built out on the base tables.

    Also, if they are using the Linq to SQL portion where Linq is building out the SQL code....look out!

    John Rowan

    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • Yeah, thats going to be messy isn't it..


Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply