Invalid object name 'dbo.AspNetUsers' in Asp.NET MVC 5 Entity Framework

后端 未结 7 538
悲哀的现实
悲哀的现实 2020-12-06 02:33

If you have an existing database, and you want to include ASP.NET Identity tables to it, you can face this error. You may not know how to integrate [AspNetRoles], [A

7条回答
  •  佛祖请我去吃肉
    2020-12-06 03:13

    I have faced same problem, Here I was forget to call EnsureCreated(). After calling this method it will create all tables required by Identity.

    Startup.cs

    public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider serviceProvider)
    {
            ...
    
            // Make sure we have the database
            serviceProvider.GetService().Database.EnsureCreated();
    }
    

提交回复
热议问题