简体   繁体   中英

Linq to SQL: View to Table Association not generating code

I have a dmbl with a bunch of tables and some views where I set up an Association in the Designer from the View to the Table. Then in code I try and write some code that "uses" that association and it isn't there. I look in the designer file and I don't see anything in there either.

Strange thing is I have done this before successfully with these same tables and views in a different dbml and project. All that changed was we moved everything from a 2005 SQL Server to a 2008R2 Box.

Linq2SQL does this if your 'view' does not have a primary key. So add a pseudo one L2S can use. :)

Views can be added to the design and manual associations can be added between them and other tables/views. However, the association will not create a parent/child property in the code unless you modify the view properties to define "primary keys".

https://conficient.wordpress.com/2008/06/04/linq-to-sql-faq-associations-to-views/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM