[英]Entity Framework - adding new column to view generates null pointer exception
I have a working project, but when I try to insert a new column into a view in entity framework as follows : The Mapper class of view contains : 我有一个正在运行的项目,但是当我尝试向实体框架中的视图中插入新列时,如下所示:视图的Mapper类包含:
namespace DBRefresh.Models.Mapping
{
public class v_Report_HIVE_Roadmap_AnalyticsMap : EntityTypeConfiguration<v_Report_HIVE_Roadmap_Analytics>
{
public v_Report_HIVE_Roadmap_AnalyticsMap()
{
// Primary Key
this.HasKey(t => new { t.Solution_ID_and_Name, t.Viz_Status, t.t_f, t.Updated_MR,
t.Governance_Team, t.Tied_to_a_Heavyweight_Solution, t.Solution_Type, t.Is_Dup_,t.ROW_NUM });
this.Property(t => t.ROW_NUM).IsRequired();
//other properties defined
//table column and mapping
this.Property(t => t.ROW_NUM).HasColumnName("ROW_NUM");
}
}
}
The Model Class has the following: 模型类具有以下内容:
namespace DBRefresh.Models
{
public partial class v_Report_HIVE_Roadmap_Analytics
{
public long Row_NUM{ get; set; }
}
}
I get a Null Pointer exception when I try to read data from the db. 当我尝试从数据库读取数据时,出现Null Pointer异常。 The data is read through various controllers so cannot directly write here, but they all work fine until I add this new column.
数据是通过各种控制器读取的,因此无法在此处直接写入,但是在我添加此新列之前,它们都可以正常工作。 On adding this column which I have made as a primary key in my view, I get the null pointer exception on the very first table that my application reads.
添加在我的视图中作为主键创建的该列后,我在应用程序读取的第一个表上得到了空指针异常。
Database structure for the view is : 该视图的数据库结构为:
SELECT *, ISNULL(ROW_NUMBER() OVER(ORDER BY Industry),-1) as ROW_NUM
FROM (
Select ....)
The view contains this column as ROW_NUM(bigint,not null) 视图包含此列为ROW_NUM(bigint,not null)
Trying to figure out the cause for days, Any help would be appreciated. 试图找出原因的日子,任何帮助将不胜感激。
Go to the model folder select the model
> right click
> select update model from database
> refresh > finish 转到模型文件夹,选择
model
> right click
> select update model from database
>刷新>完成
I hope this helps. 我希望这有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.