gpt4 book ai didi

c# - "Invalid object name ' dbo.Memberships '."尝试添加新用户时

转载 作者:行者123 更新时间:2023-11-30 13:06:32 25 4
gpt4 key购买 nike

我在过去一两天内做了一些事情破坏了我的申请。

我有一种方法可以使用成员(member)提供程序在成员(member)数据库中创建新用户。

例如

 public void Create(Consumer consumer)
{

MembershipCreateStatus status;
if (consumer.UserId == Guid.Empty)
{
consumer.UserId = Guid.NewGuid();
}
if (consumer.ConsumerId == Guid.Empty)
{
consumer.ConsumerId = Guid.NewGuid();
}
try
{
var membershipUser = Membership.CreateUser(consumer.UserName, consumer.Password, consumer.Email, null, null, consumer.IsApproved, consumer.UserId, out status);
....
}

内部异常是

{"Invalid object name 'dbo.Memberships'."}

堆栈跟踪是

at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior) at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues) at System.Data.Objects.ObjectQuery1.GetResults(Nullable1 forMergeOption) at System.Data.Objects.ObjectQuery1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable
1 source) at System.Data.Objects.ELinq.ObjectQueryProvider.b__1[TResult](IEnumerable1 sequence)
at System.Data.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable
1 query, Expression queryRoot) at System.Data.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[S](Expression expression) at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source) at System.Web.Providers.QueryHelper.GetMembership(MembershipEntities ctx, String applicationName, Guid userId) at System.Web.Providers.DefaultMembershipProvider.Membership_CreateUser(String applicationName, String userName, String password, String salt, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, DateTime& createDate, Boolean uniqueEmail, Int32 passwordFormat, Object& providerUserKey) at System.Web.Providers.DefaultMembershipProvider.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, Object providerUserKey, MembershipCreateStatus& status) at System.Web.Security.Membership.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, Object providerUserKey, MembershipCreateStatus& status) at Plenfy.Api.Models.ConsumerRepository.Create(Consumer consumer) in c:\@Code\Customers\Api\Repository\ConsumerRepository.cs:line 121

我不知道如何解决这个问题。数据库和连接字符串看起来很好,我可以使用 EF 连接到它。

任何人都可以建议如何深入了解这个问题吗?

最佳答案

try to use 
MembershipCreateStatus status;
if (consumer.UserId == Guid.Empty)
{
consumer.UserId = Guid.NewGuid();
}
if (consumer.ConsumerId == Guid.Empty)
{
consumer.ConsumerId = Guid.NewGuid();
}
try
{
var membershipUser = System.Web.Security.Membership.CreateUser(consumer.UserName, consumer.Password, consumer.Email, null, null, consumer.IsApproved, consumer.UserId, out status);
}

关于c# - "Invalid object name ' dbo.Memberships '."尝试添加新用户时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10923140/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com