发布ASP.NET MVC 5网站到Windows Azure [英] Publish ASP.NET MVC 5 website to Windows Azure

查看:136
本文介绍了发布ASP.NET MVC 5网站到Windows Azure的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近用asp.net MVC应用程序更改为使用MVC 5它还使用实体框架6.

I have recently changed by asp.net MVC app to use MVC 5. It also uses entity framework 6.

我已经发布到Azure的网站无数次,在过去,但从来没有两个code第一次迁移的配置。我觉得这是我的问题,但我不知道如何解决它。

I have published to Azure Website numerous times in the past, but never with two code first migration configurations. I think this is my problem but I don't know how to fix it.

我有两个班的DbContext。一个是我的域模型,另一个身份机型。在我的本地开发机器这使我没有问题。我也有在身份配置类种子的方法来创建初始用户登录的,因为我的很多控制器要求[授权]属性。

I have two DbContext classes. One for my domain models and the other for the Identity models. On my local development machine this has caused me no issues. I also have a seed method in the Identity configuration class to create a initial user to login as, since many of my controllers require the [Authorize] attribute.

我有两个迁移配置类,一个为每个上下文。我创建了一个新的Windows Azure网站和链接的SQL数据库吧。

I have two migration configuration classes, one for each context. I have created a new Windows Azure Website and linked an SQL database to it.

我已经下载了我发布,我已经习惯了出版我的网站的个人资料。我看到了发布Web对话框的设置选项卡上的两个上下文。我选择了从现有的每一个我的环境中,选择使用连接字符串在运行时的列表中选择适当的数据库启用执行code首先迁移为背景。

I have downloaded my publish profile which I have used to publish my site. I see both contexts on the settings tab of the Publish Web dialog box. I have selected the appropriate database from the list available for each of my contexts, chosen to use the connection string at runtime and enabled Execute Code First Migrations for both contexts.

当我终于发布现场这一切似乎顺利。我看到文件通过FTP连接到站点和站点出现。

When I finally Publish the site it all seems to go well. I see the files through an FTP connection to the site and the site comes up.

然而,当我试图登录我得到一个错误,说明

However, when I attempt to log in I get an error stating

The ConnectionString property has not been initialized.

在我点击我的帐户/登录查看登录按钮。

After I click the Login button on my Account/Login view.

当我检查表使用SSMS我看到没有表已在SQL被创建。

When I check the tables uses SSMS I see that no tables have been created in SQL.

我可以看到我的web.config文件已更新。原来的连接字符串已更改为指向Azure数据库。其他三个连接字符串已被添加。一个更对已附加了_DatabasePublish域上下文,以及两个用于上下文用于标识上下文,一个有一不带_DatabasePublish后缀

I can see that my web.config file has been updated. The original connection string has been changed to point to the azure database. Three other connections strings have been added. One more for the domain context that has been appended with _DatabasePublish, and two for the context used for the Identity context, one with and one without the _DatabasePublish suffix.

任何人都可以看到我可能是做错了。我使用的Azure与在此之前的解决方案,也没有问题。如果您需要任何其他code段请说。

Can anyone see what I might be doing wrong. I've used Azure with this solution before and had no problems. Please say if you need any other code snippets.

非常感谢。

编辑...

我发现了另一篇文章,建议将以下内容:

I found another post that suggested the following:

public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
    public ApplicationDbContext()
        : base("SalonContext", throwIfV1Schema: false) // throwIfV1Schema:false was added as the Identity V2 was causing an error in Azure
    {
    }

}

给它一个尝试,让我知道你上车。

Give it a try and let me know how you get on.

推荐答案

这为我工作。

public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
    public ApplicationDbContext()
        : base("SalonContext", throwIfV1Schema: false) // throwIfV1Schema:false was added as the Identity V2 was causing an error in Azure
    {
    }

}

有得做Azure和更新的身份SDK。

Something to do with Azure and the updates to the identity SDK.

这篇关于发布ASP.NET MVC 5网站到Windows Azure的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆