Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用Azure数据库(ASP.NET MVC)_C#_Asp.net_Asp.net Mvc_Asp.net Mvc 4_Azure - Fatal编程技术网

C# 使用Azure数据库(ASP.NET MVC)

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

我是ASP.NET开发的新手

我创建了MVC项目,据我所知,它使用default.mdf数据库创建

我使用它,一切都很好,但我考虑将应用部署到azure

所以我需要使用azure数据库

我创造它,一切都好

我读了一篇关于如何连接到azure db的文章

据我所知,我需要连接字符串

给你

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中关闭自定义错误以查看它。否则我们只能猜测。