c# - EF Core inherited class data annotation
问题描述
I'm writing a web app using Core 2.0 MVC. With the help of EF I'm trying to create (code first) models to model the database so I can automate the whole db creation process using migration.
My issue, I'm using a third party library to interact with an API (this library was built specifically to interact with this API) but the data that the API returns I'd like to store in a db using the same schema as the class from the library.
As an example Third party library
public class PersonDetails
{
public long PersonID { get; set; }
public string PersonName { get; set; }
}
If i try to create a migration for this class it complains about no primary key being set, I'm unable to modify this class. Is there a way that I can set the [Key] attribute for PersonID from an inherited class or something similar?
解决方案
推荐阅读
- uwp - XDG0062 未能在索引 0 处检索子项
- c# - Unity Editor 在运行计时器时冻结
- python - 如何在python中找到两个最大的特征向量?
- php - 重力形式 -> 重力流:取消工作流时更改字段数据
- arrays - 全局二维数组值在模块之间变化
- sql - Teradata SQL - 拆分字符串,字符串具有列名和值
- java - Jetty 11 - 仅当文件是视频时上传失败
- c# - 成功登录本地应用程序后,如何从网站的登录页面获取访问令牌
- r - 地图上ggplot2中的地图密度
- graphql - Graphql Ariadne table_aggregate 未记录