簡體   English   中英

Foo在UserManager.CreateAsync上的關系欄錯誤上的角色沖突更改

[英]Conflicting changes to the role of Foo on relationship Bar error on UserManager.CreateAsync

好的,我看到有關實體框架“在關系欄上Foo的角色發生沖突更改”錯誤的許多其他問題,答案似乎都圍繞着更改與數據庫交互的代碼。

我無法在此處執行此操作,因為在UserManager.CreateAsync上收到此錯誤,因此我需要更改模型。

確切的錯誤消息如下:

已檢測到對關系“ Myproject.Models.ApplicationUser_Customer”的角色“ ApplicationUser_Customer_Target”的沖突更改。

好的,這里是ApplicationUser:

public class ApplicationUser : IdentityUser
{
    private CustomerModel _customer;

    public CustomerModel Customer
    {
        get
        {
            return _customer ?? new CustomerModel();
        }
        set { _customer = value; }
    }
}

這是CustomerModel:

public sealed class CustomerModel
{
    public string Id { get; set; }
}

我為此創建了一個遷移,並使用Updte-Database方法更新了數據庫。

這是SQL Server Management Studio的屏幕截圖:

屏幕快照顯示關系

我對此完全感到困惑,我在這里做錯了什么?

謝謝

在問了一個問題之前,我為此苦了一個小時,然后立即解決了。

為了使代碼的另一部分正常工作,如果ApplicationUser中的私有后備字段為null,我將返回Customer的實例。

這導致CreateUser方法崩潰並死亡。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM