PLEASE include the database in the source!

Jun 19, 2011 at 5:22 AM

Is there a database to go along with this project? It is using a sqlexpress database name OdeToFoodDB. Can you please throw it up there for download please? Thanks much!

Coordinator
Oct 24, 2011 at 7:49 PM

When you run the application, the Entity Framework (version 4.1) will create the database from the C# class definitions. All you need is a local instance of SQL Express. 

Mar 15, 2012 at 5:16 PM

Where do you get the "LegacyOdeToFoodDB" referenced in Module 5 (Working with Data Part II)? I just modified the original OdeToFoodDB to follow along, but now am getting an error because of an invalid column name "DiningDate" because it does not exist in my database. I can create this column, but will I continue to run into bugs without the Legacy database used in the module? Thanks!

Mar 15, 2012 at 7:38 PM

I was able to fix this by changing the name of the field "Created" in the Reviews table to "DiningDate". Everything else seems to be working now.

Apr 29, 2013 at 9:51 PM
Hi, i was following alone the OdeToFoodDb, after i build the application and run it, the entity framework did not automcally create a localdb from the OdeToFooddb.cs model file. am i missing some setting?
Coordinator
Apr 30, 2013 at 11:16 AM
Did you get an error message?
May 7, 2013 at 2:57 PM
Edited May 7, 2013 at 5:53 PM
Hello

I have already downloaded the code for MVC, the latest version(**), and the first time I run it, it did it alright.
I got a problem with Nuget and to solve it I decided to delete the folder with OdeToFood.
Then I unzipped it again as I did before but now, it doesn´t run.
A yellow page with a message about the it cannot find the database under App_Data.
Weird cos the first time it was create and was working.
(**)By the way, I downloaded a version of FEB 08, 2013, but I don't remember from where.

Here's the message:

Server Error in '/' Application.

Cannot attach the file 'D:\PROJECTS\VISUAL STUDIO work\K.ScottAllen\OdeToFood\odetofoodmvc4-(Feb 08, 2013)\OdeToFood\App_Data\OdeToFoodDb.mdf' as database 'OdeToFoodDb'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Cannot attach the file 'D:\PROJECTS\VISUAL STUDIO work\K.ScottAllen\OdeToFood\odetofoodmvc4-(Feb 08, 2013)\OdeToFood\App_Data\OdeToFoodDb.mdf' as database 'OdeToFoodDb'.

Source Error:



Line 22:
Line 23: var migrator = new DbMigrator(new Configuration());
Line 24: migrator.Update();
Line 25:
Line 26: if (!WebSecurity.Initialized)


Source File: d:\PROJECTS\VISUAL STUDIO work\K.ScottAllen\OdeToFood\odetofoodmvc4-(Feb 08, 2013)\OdeToFood\Global.asax.cs Line: 24

Stack Trace:



[SqlException (0x80131904): Cannot attach the file 'D:\PROJECTS\VISUAL STUDIO work\K.ScottAllen\OdeToFood\odetofoodmvc4-(Feb 08, 2013)\OdeToFood\App_Data\OdeToFoodDb.mdf' as database 'OdeToFoodDb'.]
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +414
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +78
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource
1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +167
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) +143
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1 retry) +83
System.Data.SqlClient.SqlConnection.Open() +96
System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable1 migrationStatements) +91
System.Data.Entity.Migrations.Infrastructure.MigratorBase.ExecuteStatements(IEnumerable
1 migrationStatements) +42
System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String migrationId, XDocument targetModel, IEnumerable1 operations, Boolean downgrading, Boolean auto) +1025
System.Data.Entity.Migrations.DbMigrator.ApplyMigration(DbMigration migration, DbMigration lastMigration) +494
System.Data.Entity.Migrations.Infrastructure.MigratorBase.ApplyMigration(DbMigration migration, DbMigration lastMigration) +56
System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable
1 pendingMigrations, String targetMigrationId, String lastMigrationId) +186
System.Data.Entity.Migrations.Infrastructure.MigratorBase.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId) +59
System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) +896
System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update() +33
OdeToFood.MvcApplication.Application_Start() in d:\PROJECTS\VISUAL STUDIO work\K.ScottAllen\OdeToFood\odetofoodmvc4-(Feb 08, 2013)\OdeToFood\Global.asax.cs:24

[HttpException (0x80004005): Cannot attach the file 'D:\PROJECTS\VISUAL STUDIO work\K.ScottAllen\OdeToFood\odetofoodmvc4-(Feb 08, 2013)\OdeToFood\App_Data\OdeToFoodDb.mdf' as database 'OdeToFoodDb'.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9859441
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

[HttpException (0x80004005): Cannot attach the file 'D:\PROJECTS\VISUAL STUDIO work\K.ScottAllen\OdeToFood\odetofoodmvc4-(Feb 08, 2013)\OdeToFood\App_Data\OdeToFoodDb.mdf' as database 'OdeToFoodDb'.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9873784
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101

System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18034