【发布时间】:2020-11-17 13:48:32
【问题描述】:
我有两个实体,
Book.cs
public class Book
{
public int Id { get; set }
public string Name { get; set; }
public string ReferenceNo { get; set; }
public int AuthorId { get; set; }
public Author Author { get; set; }
}
Author.cs
public class Author
{
public int Id { get; set }
public string Name { get; set; }
public List<Book> Books { get; set; }
}
选择我正在尝试的所有书籍:
var query = "select * from Books as book join Authors as author on author.Id = book.AuthorId";
_context.Books.FromSqlRaw(query).ToList()
但是我得到了这里显示的异常,它告诉我Name 列已经存在,但我很困惑,因为它们是不同的类型。
已添加具有相同密钥的项目。键:名称```
【问题讨论】:
标签: c# sql-server entity-framework .net-core entity-framework-core