Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.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
Sqlite 在“上使用无键实体”;“许多”;一对多关系中的一方?_Sqlite_Entity Framework Core_Foreign Keys_One To Many - Fatal编程技术网

Sqlite 在“上使用无键实体”;“许多”;一对多关系中的一方?

Sqlite 在“上使用无键实体”;“许多”;一对多关系中的一方?,sqlite,entity-framework-core,foreign-keys,one-to-many,Sqlite,Entity Framework Core,Foreign Keys,One To Many,我将实体框架核心5.0用于SQLite,并且有这样的模式: 创建表元素( id整数不是空主键, 标题文本不为空 ); 创建表属性( elemId整数不为空, 名称文本不为空, 值浮动不为空 ); 我创建了以下类: [表(“元素”)] 公共类dbElem{ [关键] 公共长id{get;set;} 公共字符串名称{get;set;} 公共虚拟ICollection道具{get;set;} } [表(“财产”)] 公共类dbProperty{ 公共长elemId{get;set;} 公共虚拟数据库

我将实体框架核心5.0用于SQLite,并且有这样的模式:

创建表元素(
id整数不是空主键,
标题文本不为空
);
创建表属性(
elemId整数不为空,
名称文本不为空,
值浮动不为空
);
我创建了以下类:

[表(“元素”)]
公共类dbElem{
[关键]
公共长id{get;set;}
公共字符串名称{get;set;}
公共虚拟ICollection道具{get;set;}
}
[表(“财产”)]
公共类dbProperty{
公共长elemId{get;set;}
公共虚拟数据库元素{get;set;}
公共字符串名称{get;set;}
公共双值{get;set;}
}
OnModelCreating
函数中,我编写了以下内容:

modelBuilder.Entity(Entity=>{
entity.HasNoKey();
entity.HasOne(f=>f.elem).WithMany(f=>f.props).HasForeignKey(f=>f.elemId).OnDelete(DeleteBehavior.Cascade);
});
所有内容看起来都符合逻辑,但我收到一个错误:
System.invalidoOperationException:“无法添加导航“”,因为它以无键实体类型“dbProperty”为目标。”。导航只能针对具有键的实体类型。“

这种限制有什么原因吗?

我是否可以影响EFC不添加密钥?