我在ApplicationUser
类中添加了以下更改:
public class ApplicationUser : IdentityUser<int, CustomUserLogin, CustomUserRole, CustomUserClaim>
{
public string FirstName { get; set; }
public string LastName { get; set; }
public virtual int OrganizationId { get; set; }
public virtual int? ProfilePictureId { get; set; }
public bool IsBroker { get; set; }
[ForeignKey("OrganizationId")]
public virtual Organization UserOrganization { get; set; }
[ForeignKey("ProfilePictureId")]
public virtual File UserProfilePicture { get; set; }
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser, int> manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
}
问题是Organization
和File
与IdentityFramework使用dbo
的架构不在同一架构中。
当我尝试使用该元素获取该用户的Organization
信息时:
ApplicationUser currentUser = (from u in dbIdentity.Users
where u.Id == var1
select u).SingleOrDefault();
string organizationName = currentUser.UserOrganiztion.OrganizationName;
它试图让dbo.Organizations
不存在并且在另一个模式中。
是否可以更改正在使用的架构?如果是这样的话?
谢谢!