Download code and slides here
Note the file is ~25MB because of the size of the embedded databases. Unzipped around 60MB or so for all of the projects (again mostly because of the databases)
Let me know if you have any problems setting it up. The first couple slides contain some notes on the projects.
Thanks for attending!!!
I realize it was a _ton_ of information to throw at you. This could easily have been turned into a 4+ hour talk but there's a reason I put all of that in this talk. If you are new to MVC it makes it even more difficult, but I feel these are all areas important to getting up and running effectively on MVC. Where to start if you are new? Create a new mvc 3 project. Now go through the slides and create each item. Create a route. Create a model, a controller, a view. Then save data using the PRG pattern. Then try to load some data into a div via an ajax call or even just an ajax form using @Ajax.BeginForm. This will get you off to a nice start - just let me know if you have any questions - I'll try to steer you in the right direction : )
Windows 8, ASP.NET, Entity Framework, Architecture, and various musings
Saturday, April 23, 2011
Entity Framework Error - The relationship '{0}' was not loaded because the type '{1}' is not available.
I had changed an applications data architecture slightly and instead of going to a network Sql Server instance, I decided to use the App_Data folder to make this application distribute a bit easier for demo purposes.
This error was caused because my connect string wasn't correct to the database. The connect strings for App_Data databases use a local path to attach to a database file such as:
AttachDbFilename=|DataDirectory|\MyDatabase.mdb
I thought my connect string was correct in the web.config of the application that used my data access layer and the error doesn't of course tell me anything is wrong with my connect string, but I figured I'd give it a try.
In order to properly reference my database in _another project_ I needed the dialog to give me the connect string to make sure it was all 100% ok, and then I just would edit the db path to be relative from the absolute path the dialog displays. So - I went back into my data access project and selected to add a new entity framework model. When the dialog came up, I simply copied the app_data database connectstring and then canceled out of the dialog and updated my other project's web.config:
Schema specified is not valid. Errors:
The relationship 'NASA.FK_Booster_Catalog' was not loaded because the type 'NASA.Catalog' is not available.
Exception Details: System.Data.MetadataException: Schema specified is not valid. Errors:
The following information may be useful in resolving the previous error:
The required property 'Password' does not exist on the type 'NASA.DataAccess.Models.Catalog'.
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.
The required property 'Password' does not exist on the type 'WebStore.DataAccess.Models.Customer'.
Source Error:
Line 69: public ObjectSet Products
Line 70: {
Line 71: get { return _catalogs ?? (_catalogs = CreateObjectSet("Catalogs")); }
Line 72: }
Line 73: private ObjectSet _catalogs;
Stack Trace:
System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(ObjectItemCollection objectItemCollection, Assembly assembly, Boolean loadReferencedAssemblies, EdmItemCollection edmItemCollection, Action`1 logLoadMessage) +480
System.Data.Metadata.Edm.ObjectItemCollection.ImplicitLoadAssemblyForType(Type type, EdmItemCollection edmItemCollection) +84
System.Data.Metadata.Edm.MetadataWorkspace.ImplicitLoadAssemblyForType(Type type, Assembly callingAssembly) +151
System.Data.Objects.ObjectContext.GetTypeUsage(Type entityCLRType) +35
System.Data.Objects.ObjectContext.GetEntitySetForNameAndType(String entitySetName, Type entityCLRType, String exceptionParameterName) +33
System.Data.Objects.ObjectContext.CreateObjectSet(String entitySetName) +66
..
..
..
This error was caused because my connect string wasn't correct to the database. The connect strings for App_Data databases use a local path to attach to a database file such as:
AttachDbFilename=|DataDirectory|\MyDatabase.mdb
I thought my connect string was correct in the web.config of the application that used my data access layer and the error doesn't of course tell me anything is wrong with my connect string, but I figured I'd give it a try.
In order to properly reference my database in _another project_ I needed the dialog to give me the connect string to make sure it was all 100% ok, and then I just would edit the db path to be relative from the absolute path the dialog displays. So - I went back into my data access project and selected to add a new entity framework model. When the dialog came up, I simply copied the app_data database connectstring and then canceled out of the dialog and updated my other project's web.config:
Schema specified is not valid. Errors:
The relationship 'NASA.FK_Booster_Catalog' was not loaded because the type 'NASA.Catalog' is not available.
Exception Details: System.Data.MetadataException: Schema specified is not valid. Errors:
The following information may be useful in resolving the previous error:
The required property 'Password' does not exist on the type 'NASA.DataAccess.Models.Catalog'.
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.
The required property 'Password' does not exist on the type 'WebStore.DataAccess.Models.Customer'.
Source Error:
Line 69: public ObjectSet
Line 70: {
Line 71: get { return _catalogs ?? (_catalogs = CreateObjectSet
Line 72: }
Line 73: private ObjectSet
Stack Trace:
System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(ObjectItemCollection objectItemCollection, Assembly assembly, Boolean loadReferencedAssemblies, EdmItemCollection edmItemCollection, Action`1 logLoadMessage) +480
System.Data.Metadata.Edm.ObjectItemCollection.ImplicitLoadAssemblyForType(Type type, EdmItemCollection edmItemCollection) +84
System.Data.Metadata.Edm.MetadataWorkspace.ImplicitLoadAssemblyForType(Type type, Assembly callingAssembly) +151
System.Data.Objects.ObjectContext.GetTypeUsage(Type entityCLRType) +35
System.Data.Objects.ObjectContext.GetEntitySetForNameAndType(String entitySetName, Type entityCLRType, String exceptionParameterName) +33
System.Data.Objects.ObjectContext.CreateObjectSet(String entitySetName) +66
..
..
..
I finally joined 2011 and created my twitter account
My twitter account is @AdamTuliper - I feel so 'modern' : ) Stay tuned for various links, updates, tech ed info, etc!
Friday, April 22, 2011
MVC MVC MVC
Its been a busy couple weeks!! Presentations in NYC, Philly, CT, and now Tech Ed Atlanta coming up. For those that attended the MVC presentation on "Learning MVC for the Web Forms Developer" - Thanks! I'll be posting the code and slides shortly, I just need to make sure the projects don't just work on my machine and are easy for you to setup - including database access. Please check back shortly, hopefully this weekend I'll have everything up there.
A special thanks to the guys that took me out after last nights Manhattan presentation for a couple brews : )
A special thanks to the guys that took me out after last nights Manhattan presentation for a couple brews : )
Subscribe to:
Posts (Atom)
