How to migrate table?
I have database with table: Quote, so i tried to migrate new table Author on database using package manager console but there's an error:
System.InvalidOperationException: 'Cannot use table 'Quote' for entity type 'Sample' since it is being used for entity type 'Author' and potentially other entity types, but there is no linking relationship. Add a foreign key to 'Sample' on the primary key properties and pointing to the primary key on another entity typed mapped to 'Quote'.'
Here my Author.cs model:
Here my Sample.cs model:
and here RepositoryContext.cs:
3 Replies
@Angius can you help me?
Why is it called "Sample" if it's a quote..?
Seems like you were trying to do some other stuff before, tables had different names and what not, and EF is confused now. Dropping the database, deleting the migrations, and creating a fresh migration often helps.
I thought that when declare the [Table: Quote] will help, okay i will try to edit that and create fresh migration. Thanks:)