- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 ASP.net 的 MVC 3(使用 VB)的新手,我正在尝试创建一个可以连接到 SQL 2008 服务器数据库的应用程序。我已经阅读了一个教程(Microsoft ASP.net 的 Movie DB 教程),但该教程使用的是 SQL 精简版。我很难连接。我是否正确假设一旦我创建了一个模型,我应该能够通过更改 Web.config 文件中的连接字符串来连接到 SQL 2008,该文件位于应用程序文件夹的根目录?我从 App_Data 文件夹中删除了 sql ce 数据库。在 Microsoft SQL Server Management Studio 中,我创建了一个新数据库。然后我将它添加到我的 Web.config 文件中:
<connectionStrings>
<add name="ConnectionName"
providerName="System.Data.SqlClient"
connectionString="Data Source=DELERIUM-PC;Initial Catalog=iDjItDb;Integrated Security=True" />
</connectionStrings>
The model backing the 'iDjItDBContext' context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance. For example, the DropCreateDatabaseIfModelChanges strategy will automatically delete and recreate the database, and optionally seed it with new data.
最佳答案
您可以删除 IncludeMetadataConvention
在您的上下文类中,如果您确定您的模型与数据库兼容。
public class iDjItDBContext : DBContext
{
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<IncludeMetadataConvention>();
}
}
Application_Start()
中设置初始化器您的方法
Global.asax.cs
文件。
Database.SetInitializer<iDjItDBContext>(
new DropCreateDatabaseIfModelChanges<iDjItDBContext>());
iDjItDBContext
以便名称与
DbContext
匹配姓名。
<connectionStrings>
<add name="iDjItDBContext"
providerName="System.Data.SqlClient"
connectionString="Data Source=DELERIUM-PC;Initial Catalog=iDjItDb;Integrated Security=True" />
</connectionStrings>
public class iDjItDBContext : DBContext
{
public iDjItDBContext() : base("ConnectionName")
{
}
}
关于asp.net-mvc-3 - 使用 MVC 3 ASP.net 连接到 SQL Server 2008,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8887921/
我正在开发一个 voip 调用应用程序。我需要做的是在接到来电时将 Activity 带到前台。我在应用程序中使用 Twilio,并在收到推送消息时开始调用。 问题是我试图在接到任何电话时显示 Act
我是一名优秀的程序员,十分优秀!