简体   繁体   English

数据库第一个EntityType'表'没有定义键。 定义此EntityType的键

[英]Database First EntityType 'table' has no key defined. Define the key for this EntityType

I Create the model starting from a Oracle Database. 我从Oracle数据库开始创建模型。 In the table that I picked there isn't a primary key so the entity framework complains about that and it is not able to generate the classes correctly. 在我选择的表中没有主键,因此实体框架对此有所抱怨,并且无法正确生成类。 Do you know a way to generate the model in the correct way without adding the primary key to the database? 您是否知道以正确的方式生成模型而不向数据库添加主键的方法?

One way of adding a primary key to a table after you have created your model is to open this file [1]: https://i.stack.imgur.com/6vJhP.png . 创建模型后,向表添加主键的一种方法是打开此文件[1]: https : //i.stack.imgur.com/6vJhP.png Once inside you will see all the relevant tables on the model. 进入内部后,您将看到模型上的所有相关表。 [1]: https://i.stack.imgur.com/bSIsK.png . [1]: https : //i.stack.imgur.com/bSIsK.png Right click on the column you wish to make the primary key, you will see the wording "Entity Key", make sure this is ticked/selected as in the image. 右键单击要用作主键的列,您将看到“实体键”字样,确保已选中/选中该键,如图中所示。 Save the model, and rebuild project. 保存模型,然后重建项目。 This should be done on all tables complaining of primary keys. 应该在抱怨主键的所有表上执行此操作。 Hope it helps. 希望能帮助到你。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 EntityType没有定义键。 定义此EntityType的键 - EntityType has no key defined. Define the key for this EntityType EntityType X没有定义键。 定义此EntityType的键 - EntityType X has no key defined. Define the key for this EntityType EntityType“帖子”没有定义键。 定义此EntityType的键 - EntityType 'posts' has no key defined. Define the key for this EntityType EntityType'MyProfile'没有定义键。 定义此EntityType的键 - EntityType 'MyProfile' has no key defined. Define the key for this EntityType EntityType 'Worker' 没有定义键。 定义此 EntityType 的键 - EntityType 'Worker' has no key defined. Define the key for this EntityType 代码优先-EntityType'编译器结果'尚未定义键。 定义此EntityType的键 - Code First - EntityType 'Compiler Results' has no key defined. Define the key for this EntityType 代码优先:EntityType 'xxxx' 没有定义键。 添加 n 对 n 关系时定义此 EntityType 的键 - Code first: EntityType 'xxxx' has no key defined. Define the key for this EntityType when adding n-to-n relationship EntityType''没有定义键。 定义此EntityType的键。 -C#Web API实体框架 - EntityType ' ' has no key defined. Define the key for this EntityType. - C# Web API Entity Framework 实体框架4.3.1 - > 5.0异常:“EntityType没有定义键。 定义此EntityType的键。“ - Entity Framework 4.3.1 -> 5.0 Exception: “EntityType has no key defined. Define the key for this EntityType.” EF 5.0 Fluent映射:“ EntityType'{ClassMap}'”未定义键。 定义此EntityType的密钥。” - EF 5.0 Fluent mapping: “EntityType '{ClassMap}' has no key defined. Define the key for this EntityType.”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM