0
我正在用EF代碼先創建一個小應用程序,我想從包管理器控制檯調用update database命令並將數據庫定位到我的應用程序中。配置這是一個本地.mdf。實體框架代碼優先 - 更新數據庫在項目中找不到.mdf
我有這樣的連接字符串在我的app.config在構造
using System.Data.Entity;
using EventsApp.Entities;
namespace EventsApp.Contexts.DataContexts
{
public class RegistrantDb :DbContext
{
public RegistrantDb()
: base("EventsConnectionString")
{
}
public DbSet<Registrant> Registrants { get; set; }
}
}
我的文件結構
與連接字符串
<connectionStrings>
<add name="EventsConnectionString"
connectionString="Data Source=(localdb)\v11.0;Database=EventsApp;Trusted_Connection=Yes;" />
</connectionStrings>
RegistrantContext類
和命令來更新數據庫:
Update-Database -ConfigurationTypeName EventsApp.Contexts.DataContexts.RegistrantMigrations.Configuration -verbose
錯誤消息
Error Number:-1,State:0,Class:20
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
我相信我的設置是錯誤的,因此它不能找到Events.mdf。有誰知道我需要改變什麼?