adding a foreign key with Code First migration

前端 未结 6 1784
花落未央
花落未央 2020-12-24 02:15

I have an error when trying to update my database after adding a migration.

Here are my classes before add-migration

public class Product
{
    publi         


        
6条回答
  •  攒了一身酷
    2020-12-24 03:11

    It can occur when you try to add foreign key constraint on a non nullable column of a table that already contains data. If your tables contain data try to delete them first and retry to update your database.

提交回复
热议问题