C# 使用实体框架缺少SQLite和SQL Server CE数据库文件
我首先使用实体框架代码,我的数据库文件显然没有被创建,至少没有在磁盘上。我可以用我的程序使用数据库,一切都很好,唯一的问题是我自己找不到数据库文件,我想用它进行调试 这是我的C# 使用实体框架缺少SQLite和SQL Server CE数据库文件,c#,entity-framework,sqlite,sql-server-ce,C#,Entity Framework,Sqlite,Sql Server Ce,我首先使用实体框架代码,我的数据库文件显然没有被创建,至少没有在磁盘上。我可以用我的程序使用数据库,一切都很好,唯一的问题是我自己找不到数据库文件,我想用它进行调试 这是我的DbContext类: public class HelperEntities : DbContext { public HelperEntities() : base("HelperEntities") { } public DbSet<GuidModel> Guids { g
DbContext
类:
public class HelperEntities : DbContext
{
public HelperEntities() : base("HelperEntities") { }
public DbSet<GuidModel> Guids { get; set; }
}
公共类帮助属性:DbContext
{
公共HelperEntities():base(“HelperEntities”){}
公共DbSet Guids{get;set;}
}
连接字符串:
<add name="HelperEntities" connectionString="Data Source=NewDatabase.sdf;Encrypt Database=True;Password:nopassword1;" providerName="System.Data.SqlServerCe" />
SQL Server Compact Edition和SQLite都会出现这种情况,请在bin/debug文件夹中查找!最好的方法是在连接字符串中拥有数据库文件的完整路径。它不在生成文件夹中,即使我将特定文件夹指定为“C:\database.sdf”,它也不会在那里。它可能在您的用户配置文件文件夹中(Windows 7
C:\Users\username
)。