Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 02, 2012 02:17 PM by TabAlleman
May 01, 2012 07:36 AM|LINK
i have tbl and i have view...i need to make relation between them.
my view support delete and update and insert.
is it possible to create relation between this 2 kind of object?
May 01, 2012 07:41 AM|LINK
Yes, you can do this, but the GUI designer won't be able to infer it for you.
The first thing the need to do is configure the view correctly.The designer cannot infer the primary key, so you will need to supply
You can now right-click in the empty space in the designer and then choose to add an association. Define the association between your view and table, setting the cardinality correctly.
In EF 1, you will need to remove the FK fields from the client schema by selecting them in the designer and pressing delete. This is because, in EF 1, you cannot have the same field mapped to both an association and in a scalar property. In EF 4, you can
keep the FK fields if you use FK associations, or you can use independent associations which behave like EF 1.
May 01, 2012 08:55 AM|LINK
i dont underestand what you seid!!! just i find the link that you copy your replay from there!!!
i dont want to use the EF ...
May 01, 2012 12:48 PM|LINK
Can you show the script of your view?
You can check this link first
May 01, 2012 01:27 PM|LINK
If you mean can you create a foreign key to or from a view, then the answer is no, you cannot. However, the underlying tables in the view can have FK's, which should produce the same effect.
If you mean can you JOIN a table and a view in a query, then the answer is yes, you can.
May 02, 2012 05:54 AM|LINK
this is my table:
CREATE TABLE [dbo].[City](
[City_id] [int] IDENTITY(1,1) NOT NULL,
[Unit_id] [int] NULL,
[CityNameEn] [varchar](200) NULL,
[CityNameFa] [nvarchar](200) NULL,
[PerTel] [nvarchar](50) NULL,
[CommentFa] [ntext] NULL,
[CommentEn] [text] NULL,
and this is my View:
in this case is ti possible for cascade delete and Update?
May 02, 2012 01:56 PM|LINK
You need to understand the limitations of updatable view before you move forward.
You can try to use trigger to do something you want to do.
I don't know your requirements for the cascading part. I would consider to implement a solution at the table level.
May 02, 2012 02:17 PM|LINK
There is no need to set up a cascade between a view and its own underlying table. When records are deleted from the table, they will automatically disappear from the view.