简体   繁体   中英

The entity type 'List<Guid>' requires a primary key to be defined

The entity type 'List' requires a primary key to be defined. If you intended to use a keyless entity type, call 'HasNoKey' in 'OnModelCreating'.

I already define Id as the primary key here. but still, it's failing the Dotnet test case.

[Key]
public int Id { get; set; }

public List<Guid> Books { get; set; }

Creating a Book class would fix this. Then use List<Book> instead of List<Guid> .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM