Lightswitch Datasource views missing from list

2019-07-23 15:45发布

问题:

I just started using Lightswitch 2013 and I have created a new view in my SQL Server 2012 database but cannot see it in Lightswitch when I go to refresh the datasource. Do I have to refresh some sort of cache or something?

ALTER VIEW viw_Months 
AS 
     SELECT DISTINCT MonthKey, MonthName FROM dbo.dim_Time

The Dim.Time table has a primary key on the DateID field.

回答1:

Maybe the problem was your view doesn't have candidate column to be primary key :

LightSwitch must be able to infer a primary key for the view so that one row can be distringuished from another. If all of the view's columns are nullable then a primary key cannot be inferred and LightSwitch will not let you select it to be imported.

[social.msdn.microsoft.com : update datasource -> a particular view does not show up in list to add it to project]

Related SO Question : How do I get MS LightSwitch to recognize my View?