使用 LocalDB 开发实体框架项目时会产生以下错误...
class Initializer : DropCreateDatabaseIfModelChanges<Context>
与实体框架 6.4 一起使用Database.EnsureDeleted(); Database.EnsureCreated();
使用 Entity Framework Core 3.1调用
错误信息
An attempt to attach an auto-named database for file D:\Documents\Visual Studio-Projekte\EF-Test\bin\Debug\netcoreapp3.1\EF-DB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
连接
Context db = new Context(@"Server=(LocalDB)\MSSQLLocalDB;Integrated Security=true;AttachDbFileName="
+ Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
"EF-DB.mdf"))
发生此异常的原因是什么?