简体   繁体   English

实体框架-首先从数据库“无效的列名'discriminator''开始编码

[英]Entity Framework - Code first from database “invalid column name 'discriminator'”

I wanna ask about "invalid column name 'discriminator'". 我想问一下“无效的列名'discriminator'”。

I'm trying to access data using, for example, db.[Table-Name].ToList() . 我正在尝试使用db.[Table-Name].ToList()访问数据。 I generated my model using Entity Framework code first from database and when I try to access the table data it gives me the mentioned error. 我首先使用Entity Framework代码从数据库中生成了模型,当我尝试访问表数据时,它给了我提到的错误。

The general reason: 一般原因:

The Database field and entity class field inconsistencies caused if you have an entity class mapped to entity framework, and you add another class to your project that inherits from that class, it may break Entity Framework. 如果您有一个映射到实体框架的实体类,并且您向您的项目中添加了另一个继承自该类的类,则会导致数据库字段和实体类字段不一致。 You could mark the child class as [NotMapped] so that EF doesn't try to include it in the map. 您可以将子类标记为[NotMapped],以便EF不会尝试将其包含在地图中。 This also means you won't be able to use it in EF queries. 这也意味着您将无法在EF查询中使用它。

You might get help from the following post. 您可能会从以下帖子中获得帮助。 EF Code First "Invalid column name 'Discriminator'" but no inheritance EF代码第一个“无效的列名'Discriminator'”,但没有继承

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

相关问题 实体框架代码第一个TPH标识符列 - Entity Framework Code First TPH Discriminator Column 是否可以先在实体框架代码中使用PK列作为区分符? - Is it possible to use a PK column as a discriminator in Entity Framework code first? 在数据库表上使用代码优先实体框架的无效对象名称 - Invalid object name using code first Entity Framework on database table 实体框架代码优先 - 列ID无效 - Entity Framework Code First - Invalid column ID 如何修复“无效的列名'鉴别器'”实体框架错误 - How can I fix "Invalid column name 'Discriminator'" Entity Framework Error 实体框架代码第一列名称问题 - Entity Framework Code First column name issue 实体框架4.1代码优先–每个层次结构的表(不包含区分项) - Entity Framework 4.1 Code First – Table per Hierarchy without Discriminator Column 使用实体框架代码优先的ASP.NET MVC 3 Web应用程序上的列名ProveedoresID和UsuarioID无效 - Invalid column name ProveedoresID and UsuarioID on ASP.NET MVC 3 web app using Entity Framework Code First 首先从实体框架6数据库中的数据库中获取列名,并在映射中使用不同的属性名称 - Get the column name from the database in entity framework 6 database first with different property name in mapping 实体框架代码优先TPH,其中鉴别符大于0 - Entity Framework code first TPH where discriminator is greater than 0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM