C# 使用Azure数据库(ASP.NET MVC)
我是ASP.NET开发的新手 我创建了MVC项目,据我所知,它使用default.mdf数据库创建 我使用它,一切都很好,但我考虑将应用部署到azure 所以我需要使用azure数据库 我创造它,一切都好 我读了一篇关于如何连接到azure db的文章 据我所知,我需要连接字符串 给你C# 使用Azure数据库(ASP.NET MVC),c#,asp.net,asp.net-mvc,asp.net-mvc-4,azure,C#,Asp.net,Asp.net Mvc,Asp.net Mvc 4,Azure,我是ASP.NET开发的新手 我创建了MVC项目,据我所知,它使用default.mdf数据库创建 我使用它,一切都很好,但我考虑将应用部署到azure 所以我需要使用azure数据库 我创造它,一切都好 我读了一篇关于如何连接到azure db的文章 据我所知,我需要连接字符串 给你 Server=tcp:smartsolutionsserver.database.windows.net,1433;Initial Catalog=smartdatabase;Persist Security I
Server=tcp:smartsolutionsserver.database.windows.net,1433;Initial Catalog=smartdatabase;Persist Security Info=False;User ID={your_username};Password={your_password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
据我所知,我需要将其粘贴到Web.Release.config
我这样做,所以现在它看起来像这样
<connectionStrings>
<add name="DefaultConnection"
connectionString="Server=tcp:smartsolutionsserver.database.windows.net,1433;Initial Catalog=smartdatabase;Persist Security Info=False;User ID=*********;Password=******;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-SmartSolutions-20170124034333.mdf;Initial Catalog=aspnet-SmartSolutions-20170124034333;Integrated Security=True" providerName="System.Data.SqlClient" />
因此,我的错误出现在支持“ApplicationDbContext”上下文的模型中,该模型自数据库创建以来已发生更改
我转到表\u MigrationHistory
并删除行。在那之后,一切都好了。所有作品
@朱纳斯:谢谢你的建议。我这样做,并看到错误。如果使用IIS控制台将特定错误消息作为文本放到帖子中,也可以看到它。Imgur已关闭。您是否将Azure SQL Server上web应用的IP地址列入白名单?您需要记录发生的错误或在web.config中关闭自定义错误以查看它。否则我们只能猜测。