powered by Slim Framework
enhanced by Nesbot.com

ASP.NET: Entity Framework's Code-First with an ObjectContext

Published on Apr 30, 2012 by Jamie Munro

If the following blog interests you, it's probably because you're using Entity Framework with a Code-First approach and whatever it is you are trying to do *must* use an ObjectContext instead of the standard DbContext.  I'm sure, like me, you thought this shouldn't be too hard.  Then you started hitting roadblocks like, Metadata is required in your connection string.  What's metadata?  This is only needed in Database-First so you can tell the framework where your edmx and other definition files are, so why do I need this with Code-First, I don't have these files?

This was definitely my first reaction as well.  So after much trial-and-error and research, I have the solution!

Read more >

Tags: ASP.NET | mvc3 | entityframework | objectcontext | dbcontext

MVC 3: Pass Model or Form Data through a Redirect

Published on Feb 6, 2012 by Jamie Munro

Have you ever wanted to pass form data or perhaps even a full model from one action to another through a RedirectToAction?  By adding a new library package from NuGet, this can be accomplished with a few small changes to your controllers.

Read more >

Tags: ASP.NET | mvc3

MVC 3: Compile Views During Project Build

Published on Jan 9, 2012 by Jamie Munro

Most ASP.NET developers will use Visual Studio to build their projects. The program has evolved quite a bit over the past few years.  Including excellent features like Intellisense inside of ASP.NET MVC view files as well as some error detection in these, by default, not compiled elements.  However, when ViewBag variables are used or other run-time specific elements, Visual Studio is unable to determine potential errors in these view files.  Have no fear though; there is a nice and simple solution to help solve this problem!

Read more >

Tags: ASP.NET | mvc3

MVC 3: Accessing the RouteData inside of your code

Published on Dec 5, 2011 by Jamie Munro

You want to perform some dynamic processing in your code and you need to determine either the name of the current controller or the current action or both.

Read more >

Tags: ASP.NET | mvc3

MVC 3: Posting form variables that are not strongly typed

Published on Nov 28, 2011 by Jamie Munro

In a lot of the MVC 3 examples that are available on the Internet today, they are quite typically strongly typed to a model, e.g.


[HttpPost]
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
if (ModelState.IsValid)
{
// code here
}
}


This is extremely useful for the validation abilities and many other aspects; however, there are times when some or all of the data is not strongly typed; then what do you do?

Read more >

Tags: ASP.NET | mvc3