InnerException:表'xxx.aspnetusers'不存在

时间:2021-06-25 08:23:43

I have an ASP.NET MVC 4 Web API project which uses Entity Framework 6.1.1 and MySQL 6.9.5.0. When I call /api/Account/Register using DHC, the code breaks at

我有一个ASP.NET MVC 4 Web API项目,它使用Entity Framework 6.1.1和MySQL 6.9.5.0。当我使用DHC调用/ api / Account / Register时,代码会中断

IdentityResult result = await UserManager.CreateAsync(user, model.Password);

in the AccountController and I get an InnerException which says

在AccountController中,我得到一个InnerException,它说

Table 'xxx.aspnetusers' doesn't exist

Here are pieces of my web.config

这是我的web.config的一部分

<connectionStrings>
<add name="ClockitDb" connectionString="Data Source=ClockitDb;port=3306;Initial Catalog=ClockitDb;Server=localhost;user id=root;password=m916600026;"
  providerName="MySql.Data.MySqlClient" />
</connectionStrings>

<!-- Some code-->

<entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
<providers>
  <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
  <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers> 
</entityFramework>

<!-- Some code-->

<system.web>

<authentication mode="Forms" />
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<membership defaultProvider="MySQLMembershipProvider">
  <providers>
    <remove name="MySQLMembershipProvider" />
    <add name="MySQLMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />
  </providers>
</membership>
<profile defaultProvider="MySQLProfileProvider">
  <providers>
    <remove name="MySQLProfileProvider" />
    <add name="MySQLProfileProvider" type="MySql.Web.Profile.MySQLProfileProvider, MySql.Web, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" applicationName="/" />
  </providers>
</profile>
<roleManager defaultProvider="MySQLRoleProvider">
  <providers>
    <remove name="MySQLRoleProvider" />
    <add name="MySQLRoleProvider" type="MySql.Web.Security.MySQLRoleProvider, MySql.Web, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" applicationName="/" />
  </providers>
</roleManager>
<siteMap defaultProvider="MySqlSiteMapProvider">
  <providers>
    <remove name="MySqlSiteMapProvider" />
    <add name="MySqlSiteMapProvider" type="MySql.Web.SiteMap.MySqlSiteMapProvider, MySql.Web, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" applicationName="/" />
  </providers>
</siteMap>
<webParts>

<personalization defaultProvider="MySQLPersonalizationProvider">
    <providers>
      <remove name="MySQLPersonalizationProvider" />
      <add name="MySQLPersonalizationProvider" type="MySql.Web.Personalization.MySqlPersonalizationProvider, MySql.Web, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" applicationName="/" />
    </providers>
  </personalization>
</webParts>

<entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
  <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
  <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>

3 个解决方案

#1


4  

I had exactly the same problem . I followed the following tutorial and it worked How to set up application using ASP.NET Identity with MySQL Provider

我有完全相同的问题。我按照以下教程进行了工作,如何使用带有MySQL Provider的ASP.NET Identity设置应用程序

It is important that you follow all the steps of the tutorial,even the migration setup, otherwise it gives the same error.

请务必遵循本教程的所有步骤,甚至迁移设置,否则会出现相同的错误。

#2


1  

The exception clearly states that aspnetusers is missing from your database. However, on more findings, I think you would like to go through this answer from asp.net forum.

该例外明确指出数据库中缺少aspnetusers。但是,在更多的调查结果中,我想你想通过asp.net论坛来回答这个问题。

http://forums.asp.net/t/1977214.aspx?Mvc+5+Identity+Error+Invalid+object+name+dbo+AspNetUsers

For Role,Membership Provider, asp.net [entire asp.net stack/webapi included] with mysql, you need to have that providers specific to mysql in place. For this, you can refer to http://www.codeproject.com/Articles/117157/Setting-up-MySql-Membership-with-Visual-Studio

对于角色,成员资格提供者,asp.net [包含整个asp.net stack / webapi]和mysql,你需要有特定于mysql的提供者。为此,您可以参考http://www.codeproject.com/Articles/117157/Setting-up-MySql-Membership-with-Visual-Studio

Let me know, if this solves your problem.

让我知道,如果这解决了你的问题。

#3


-1  

I tried following the instructions on

我试着按照说明操作

http://www.codeproject.com/Articles/117157/Setting-up-MySql-Membership-with-Visual-Studio.

When I launch the security tab in ASP Website administration tool, I get an error saying

当我在ASP网站管理工具中启动安全选项卡时,我收到错误消息

The pre-application start initialization method Start on type WebMatrix.WebData.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'MySql.Data, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) (C:\Users\Jaseem Abbas\Documents\Visual Studio 2013\Projects\MySQLSample1\MySQLSample1\web.config line 33).

My line 33 in web config starts as

我在web配置中的第33行以

<membership defaultProvider="MySQLMembershipProvider">
  <providers>
    <add name="MySQLMembershipProvider"
         type="MySql.Web.Security.MySQLMembershipProvider,
         MySql.Web, Version=6.9.5.0, 
         Culture=neutral, 
         PublicKeyToken=c5687fc88969c44d"
         connectionStringName="LocalMySqlServer"
         enablePasswordRetrieval="false"
         enablePasswordReset="true"
         requiresQuestionAndAnswer="false"
         requiresUniqueEmail="true"
         passwordFormat="Hashed"
         maxInvalidPasswordAttempts="5"
         minRequiredPasswordLength="6"
         minRequiredNonalphanumericCharacters="0"
         passwordAttemptWindow="10"
         applicationName="/"
         autogenerateschema="true" />
  </providers>
</membership>
<profile>ASP
  <providers>
    <clear />
    <add type="MySql.Web.Security.MySQLProfileProvider, 
         MySql.Web, Version=6.9.5.0, 
         Culture=neutral, 
         PublicKeyToken=c5687fc88969c44d"
         name="MySqlProfileProvider"
         applicationName="/"
         connectionStringName="LocalMySqlServer"
         autogenerateschema="true" />
  </providers>
</profile>
<roleManager enabled="true" defaultProvider="MySqlRoleProvider">
  <providers>
    <clear />
    <add connectionStringName="LocalMySqlServer"
         applicationName="/"
         name="MySqlRoleProvider"
         type="MySql.Web.Security.MySQLRoleProvider, 
         MySql.Web, Version=6.9.5.0, 
         Culture=neutral, 
         PublicKeyToken=c5687fc88969c44d"
         autogenerateschema="true" />
  </providers>

#1


4  

I had exactly the same problem . I followed the following tutorial and it worked How to set up application using ASP.NET Identity with MySQL Provider

我有完全相同的问题。我按照以下教程进行了工作,如何使用带有MySQL Provider的ASP.NET Identity设置应用程序

It is important that you follow all the steps of the tutorial,even the migration setup, otherwise it gives the same error.

请务必遵循本教程的所有步骤,甚至迁移设置,否则会出现相同的错误。

#2


1  

The exception clearly states that aspnetusers is missing from your database. However, on more findings, I think you would like to go through this answer from asp.net forum.

该例外明确指出数据库中缺少aspnetusers。但是,在更多的调查结果中,我想你想通过asp.net论坛来回答这个问题。

http://forums.asp.net/t/1977214.aspx?Mvc+5+Identity+Error+Invalid+object+name+dbo+AspNetUsers

For Role,Membership Provider, asp.net [entire asp.net stack/webapi included] with mysql, you need to have that providers specific to mysql in place. For this, you can refer to http://www.codeproject.com/Articles/117157/Setting-up-MySql-Membership-with-Visual-Studio

对于角色,成员资格提供者,asp.net [包含整个asp.net stack / webapi]和mysql,你需要有特定于mysql的提供者。为此,您可以参考http://www.codeproject.com/Articles/117157/Setting-up-MySql-Membership-with-Visual-Studio

Let me know, if this solves your problem.

让我知道,如果这解决了你的问题。

#3


-1  

I tried following the instructions on

我试着按照说明操作

http://www.codeproject.com/Articles/117157/Setting-up-MySql-Membership-with-Visual-Studio.

When I launch the security tab in ASP Website administration tool, I get an error saying

当我在ASP网站管理工具中启动安全选项卡时,我收到错误消息

The pre-application start initialization method Start on type WebMatrix.WebData.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'MySql.Data, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) (C:\Users\Jaseem Abbas\Documents\Visual Studio 2013\Projects\MySQLSample1\MySQLSample1\web.config line 33).

My line 33 in web config starts as

我在web配置中的第33行以

<membership defaultProvider="MySQLMembershipProvider">
  <providers>
    <add name="MySQLMembershipProvider"
         type="MySql.Web.Security.MySQLMembershipProvider,
         MySql.Web, Version=6.9.5.0, 
         Culture=neutral, 
         PublicKeyToken=c5687fc88969c44d"
         connectionStringName="LocalMySqlServer"
         enablePasswordRetrieval="false"
         enablePasswordReset="true"
         requiresQuestionAndAnswer="false"
         requiresUniqueEmail="true"
         passwordFormat="Hashed"
         maxInvalidPasswordAttempts="5"
         minRequiredPasswordLength="6"
         minRequiredNonalphanumericCharacters="0"
         passwordAttemptWindow="10"
         applicationName="/"
         autogenerateschema="true" />
  </providers>
</membership>
<profile>ASP
  <providers>
    <clear />
    <add type="MySql.Web.Security.MySQLProfileProvider, 
         MySql.Web, Version=6.9.5.0, 
         Culture=neutral, 
         PublicKeyToken=c5687fc88969c44d"
         name="MySqlProfileProvider"
         applicationName="/"
         connectionStringName="LocalMySqlServer"
         autogenerateschema="true" />
  </providers>
</profile>
<roleManager enabled="true" defaultProvider="MySqlRoleProvider">
  <providers>
    <clear />
    <add connectionStringName="LocalMySqlServer"
         applicationName="/"
         name="MySqlRoleProvider"
         type="MySql.Web.Security.MySQLRoleProvider, 
         MySql.Web, Version=6.9.5.0, 
         Culture=neutral, 
         PublicKeyToken=c5687fc88969c44d"
         autogenerateschema="true" />
  </providers>