Skip to content

Instantly share code, notes, and snippets.

@FernandoVezzali
Last active December 29, 2015 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FernandoVezzali/7613369 to your computer and use it in GitHub Desktop.
Save FernandoVezzali/7613369 to your computer and use it in GitHub Desktop.
MVCScaffolding for MVC 5 (Visual Studio 2013)
Install-Package EntityFramework.SqlServerCompact -version 6.0.1
Install-Package MvcScaffolding -Version 1.0.8-vs2013 -Pre
public class Category {
public int CategoryId { get; set; }
public string Name { get; set; }
}
public class Product
{
public int ProductId { get; set; }
public string Name { get; set; }
public int CategoryId { get; set; }
public virtual Category Category { get; set; } // it is virtual for lazy loading (see more here: http://msdn.microsoft.com/en-us/library/dd468057.aspx)
}
Scaffold Controller Category –Repository
Scaffold Controller Product –Repository
*remove contructors
Install-Package unity.Mvc5 -version 1.1
container.RegisterType<IProductRepository, ProductRepository>(); // <--- AppStart/UnityConfig.cs
container.RegisterType<ICategoryRepository, CategoryRepository>(); // <--- AppStart/UnityConfig.cs
UnityConfig.RegisterComponents(); // <----- Add this line at global asax
// Add inside model folder
public class DataContextInitializer : DropCreateDatabaseIfModelChanges<MvcApplication2Context>{}
Database.SetInitializer<MvcApplication2Context>(new DataContextInitializer()); // at global asax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment