On the basis of a SQL Server 2008 database, the Visual Studio 2008 wizard created an Entity Framework model for me.
The model contains a view that logically connects to another table via a join table in a many-to-many connection (enforced in the database by an insert/update trigger). The view and the tables are both a part of the model, but the view does not have the connection with the join table since a view cannot have a foreign key constraint.
Is it feasible to build a connection between the join table and the view in the Entity Framework model?
Thank you for any assistance.
The GUI designer won't be able to infer this for you, but you can do it.
The first action that must be taken is setup the view properly. You must provide the main key since it cannot be deduced by the designer.
Now that there is a blank spot in the designer, you may right-click there and choose to create an association. Set the cardinality appropriately and define the relationship between your view and table.
The FK fields must be deleted from the client schema in EF 1 by selecting them in the designer and clicking the delete button. This is due to the fact that in EF 1, a field cannot be mapped to both a scalar property and an association. If you utilize FK associations in EF 4, you may maintain the FK fields, or you can use independent associations, which operate more like EF 1.