Last active
December 29, 2015 04:09
-
-
Save FernandoVezzali/7613369 to your computer and use it in GitHub Desktop.
MVCScaffolding for MVC 5 (Visual Studio 2013)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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