efcore預設會將不該轉到資料庫的model轉換到資料庫如何忽略?
於該Model類別上標記[NotMapped] 即可忽略 使ViewModel不會同樣一起migrate到DB中 還有一種可能就是去檢查你的DbContext裡面是不是有誤定義DbSet包進ViewModel EF Core Ignore https://www.learnentityframeworkcore.com/configuration/fluent-api/ignore-method ignore one table with ef-core migration https://stackoverflow.com/questions/64979208/ignore-one-table-with-ef-core-migration How to exclude one table from automatic code first migrations in the Entity Framework? https://stackoverflow.com/questions/22038924/how-to-exclude-one-table-from-automatic-code-first-migrations-in-the-entity-fram EF Core 筆記 2 - Model 設計 https://blog.darkthread.net/blog/ef-core-notes-2/