Dan*_*Dan 24 c# asp.net-mvc entity-framework entity-framework-4 ef-code-first
我已经创建了一个新的ASP.NET MVC 4应用程序,并希望它首先使用代码.但是,如果数据库文件不存在,它似乎最初不会创建数据库文件.如果我从App_Data文件夹中删除.mdf文件,那么当应用程序尝试访问数据库时,我会收到以下异常:
System.Data.SqlClient.SqlException: Cannot attach the file '<path-to-db-file>.mdf' as database '<my-db-file-name>'.
Run Code Online (Sandbox Code Playgroud)
如果我在调试器中的应用程序中运行它,那么我可以看到在调用LazyInitializer.EnsureInitialized时在InitializeSimpleMembershipAttribute :: OnActionExecuting方法中发生异常.被捕获的例外是:
[System.Reflection.TargetInvocationException] {"Exception has been thrown by the target of an invocation."} System.Reflection.TargetInvocationException
Run Code Online (Sandbox Code Playgroud)
内部例外:
[System.InvalidOperationException] {"The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588"} System.InvalidOperationException
Run Code Online (Sandbox Code Playgroud)
然后我将上面提到的第一个例外作为内部例外.
我有什么想法我做错了吗?
更新
我刚刚尝试使用全新的MVC4应用程序.我可以通过执行以下操作来复制它:
| 归档时间: |
|
| 查看次数: |
16189 次 |
| 最近记录: |