Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 生成的实体数据模型(ASP.NET MVC)缺少我在数据库中创建的视图。。为什么?_Sql Server_Asp.net Mvc_Ado.net Entity Data Model - Fatal编程技术网

Sql server 生成的实体数据模型(ASP.NET MVC)缺少我在数据库中创建的视图。。为什么?

Sql server 生成的实体数据模型(ASP.NET MVC)缺少我在数据库中创建的视图。。为什么?,sql-server,asp.net-mvc,ado.net-entity-data-model,Sql Server,Asp.net Mvc,Ado.net Entity Data Model,我在SQLServer中创建了数据库,然后在VisualStudio中使用数据库创建了实体数据模型。除了一个特定的视图之外,我所有的表和视图都生成得很好。此视图与其他视图的区别在于,我在视图语法中使用了UNION ALL。请参见下面的SQL视图设置,以及下面的Visual Studio中我的代码,该代码抱怨缺少v_contactMasterList: select clicontfin_cli_fk as clientPK, contfin_firstName as FirstName, co

我在SQLServer中创建了数据库,然后在VisualStudio中使用数据库创建了实体数据模型。除了一个特定的视图之外,我所有的表和视图都生成得很好。此视图与其他视图的区别在于,我在视图语法中使用了
UNION ALL
。请参见下面的SQL视图设置,以及下面的Visual Studio中我的代码,该代码抱怨缺少
v_contactMasterList

select clicontfin_cli_fk as clientPK,
contfin_firstName as FirstName, 
contfin_lastName as LastName, 
contfin_institutionName as InstitutionName,
contfin_contactType as ContactType 
from f_linkClientContactFinancial lccf
inner join f_contactFinancial cf on lccf.clicontfin_contfin_fk = cf.contfin_pk

UNION ALL

select clicontins_cli_fk as clientPK,
contins_agentFirstName as FirstName,
contins_agentLastName as LastName,
contins_agencyName as InstitutionName,
contins_contactType as ContactType
from f_linkClientContactInsurance lcci
inner join f_contactInsurance ci on lcci.clicontins_contins_fk = ci.contins_pk

UNION ALL

select clicontleg_cli_fk as clientPK,
contleg_FirstName as FirstName,
contleg_LastName as LastName,
contleg_firmName as InstitutionName,
contleg_contactType as ContactType
from f_linkClientContactLegal lccl
inner join f_contactLegal cl on lccl.clicontleg_contleg_fk = cl.contleg_pk

UNION ALL

select clicont_cli_fk as clientPK,
cont_FirstName as FirstName,
cont_LastName as LastName,
NULL as InstitutionName,
cont_contactType as ContactType
from f_linkClientContactPersonal lccp
inner join f_contactPersonal cp on lccp.clicont_cont_fk = cp.cont_pk
下面是我的C代码-注意,
mainDB.v#u contactMasterList.ToList()
就是问题所在。它根本无法识别
v_contactMasterList
。它可以识别所有其他数据库对象,例如“我的表”和“我的其他视图”:

public ActionResult Index()
{
   var viewModel = new ClientContactInformationViewModel
                       {
                          ClientContactRecords = mainDB.v_contactMasterList.ToList()
                       };
   return View();
 }
另外,请注意我在哪里声明了
SelectLifeManagementDBEntites
,它是如何看到的,它是从实体数据模型以及其他每个表和视图创建的


当我创建这个视图时,我只是将我的SQL语法复制并粘贴到视图SQL区域,然后执行它。然后我保存了它。我确实收到了一个对话框,上面说包含UNION ALL运算符的视图不能在图表布局中以图形方式表示。这很好,但我不知道这是否是造成问题的原因。请帮忙????提前感谢..

事实证明,我必须在视图中包含一个主键字段,以便在我的数据模型中显示该字段