1

I deleted an attribute in model of codefirst asp.net core project, and use update-databae -verbose but did not delete the attribute from table of database. Then I used update-database -verbose -force command, but received an error that it did not recognize -force.

1 Answer 1

1

Entity framework core update-database command does not have -force parameter. It's only available for remove-migration and Scaffold-DbContext commands.

You can find a complete list of commands here.

You can use Scaffold-DbContext command with -force. This way you can force scaffolding to overwrite existing model files. Be cautious when using this command.

Scaffold-DbContext "<ConnectionString>" Microsoft.EntityFrameworkCore.SqlServer -tables <tablename> -force
2
  • with this code received this error. please help me. For foreign key FK_HstJudge_IssuerHeadOffice_IssuerHeadOfficeId on table dbo.HstJudge, unable to model the end of the foreign key on principal table dbo.IssuerHeadOffice. This is usually because the principal table was not included in the selection set.
    – sadegh
    Nov 4, 2019 at 5:54
  • I've never faced this issue before and for solving this kind of issues you need to know more details about schema, models, and..., but here you can find a similar problem. If it didn't help, please ask a new question and present more details in it. If you have multiple schemas in your project, here you can find a proper workaround to prevent future issues.
    – MasLoo
    Nov 4, 2019 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.