Using SQL server views in LINQ
I have a set of SQL server views working as abstraction layer for an underlying table structure. The views are simple abstractions of the underlying tables (renaming of columns and tables) and it is in general possible to edit data using them.
Regardless if I import them in a LINQ to SQL data context or into the ADO.NET Entity Framework, the import process ignores details such as primary keys, identities or required fields of the underlying tables and generates the wrong code for data manipulations. I can repair this by editing the related properties in the designer, but a data structure update later and my changes are gone. I’m searching for a more maintainable method of doing this. Something like adding the missing key and type information开发者_Python百科 to the views, giving LINQ the information to generate the appropriate code. Any recommendations?
Ah - not use EntityFramework import tools? Thsoe are IMHO anyway pretty unusable for larger projects (more than 30-50 tables) as it really gets out of hands with its import times etc.
Maintain your mappings in code.
Have you looked at the ADO.NET Entity Framework ?
精彩评论