views:

23

answers:

1

I have a view that I have been trying to map in either entity framework or linq to sql. However when querying the view it just crashes horribly (it is just this view).

Because the error message is completly generic I thought I would just divide and conquer, and delete half the columns on my view (in sql server), and then update the DataClasses... however when I compile I get an error: "The associated metadata type for type 'test' contains the following unknown properties or fields:"... and then lists all of the fields I have deleted. I have tried to clean my solution, but still get this error.

How can I refresh the metadata?

+1  A: 

If you're dragging db objects from the server explorer into the L2S designer, then there's a bug where it caches schema information after the first round. If you do schema changes and want to re-drag the same object you need to disconnect and reconnect the server explorer thingie, or restart Visual Studio to get it to requery the db for schema info.

EF's "update model from database" shouldn't suffer from caching, but instead it has another issue where it will only update the SSDL portion of the EF model, leaving previously mapped entities/columns/etc in the CSDL in place where they become orphaned and can cause model validation failures that has to be cleaned up by hand or using 3rd party tools.

Both issues are addressed by various 3rd party tools, for a list or 3rd party tools for L2S and/or EF see:
http://www.thinqlinq.com/default/LINQ-Tools.aspx
http://damieng.com/blog/2009/06/04/linq-to-sql-resources

One of the tools addressing both of the above mentioned issues is my add-in for Visual Studio, Huagati DBML/EDMX Tools. if you want to try it out you can download it and get a trial license from http://huagati.com/dbmltools/

KristoferA - Huagati.com
thanks for the info
Grayson Mitchell