希望这个问题/答案可以帮助像我这样的人I've finished an EF Code First Project with a SQL Express database in a lab environment.Once the project is done, I've changed the DB Connection String to connect to the new Production SQL Express Database.Now, I have got the Model tables generated automatically but the AspNetUsers, AspNetRoles, AspNetUserRoles etc. are not generated automatically. I am a new learner and I need your help to know how I can get the tables back in the database.If I do update-database from the Package Manager Console, I get:Error Number:4902,State:1,Class:16Cannot find the object "dbo.AspNetUsers" because it does not exist or you do not have permissions.And also if you could explain to me how the migration works for Identity tables? 解决方案 1) Took backup of all my work2) Deleted Migration Folder3) Using SQL Management Studio, From the Production Server, Deleted the Database4) From Package Manager ConsoleEnable-Migrations -ForceAdd-Migration initUpdate-DatabaseYou know what, all the tables are back on production database now :-)Thanks to Lin fromHow to re-create database for Entity Framework?Hopefully this question/answer will help someone else like me 这篇关于更改数据库连接后,EF Code First项目不会创建AspNetUsers,AspNetRoles等表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-29 10:32