模型不使用正确的模式

时间:2016-04-12 21:17:05

标签: c# asp.net asp.net-mvc entity-framework asp.net-identity

我在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;
        }
    }

问题是OrganizationFile与IdentityFramework使用dbo的架构不在同一架构中。

当我尝试使用该元素获取该用户的Organization信息时:

ApplicationUser currentUser = (from u in dbIdentity.Users 
                               where u.Id == var1  
                               select u).SingleOrDefault();
string organizationName = currentUser.UserOrganiztion.OrganizationName;

我收到以下错误: Trying to get dbo.Organizations

它试图让dbo.Organizations不存在并且在另一个模式中。

是否可以更改正在使用的架构?如果是这样的话?

谢谢!

0 个答案:

没有答案