-
Notifications
You must be signed in to change notification settings - Fork 2
04 Hosting
Robert Friberg edited this page May 28, 2014
·
5 revisions
This module covers the different options hosting the engine and in-memory model.
In this exercise you will create a skeleton ASP.NET MVC application hosting the Todo.Core model. We will have VS generate some CRUD scaffolding that we can use as a starting point. For this purpose we need some fake classes which will be deleted once the scaffolding has been generated.
- Open the Todo solution located in the 'Ex01' folder.
- Add an MVC application to the solution called
Todo.Mvc
- Add the following classes somewhere in the project, note the namespace!
namespace Todo.Core { public class Todo { public int Id { get; set; } public string Title { get; set; } public DateTime? Due { get; set; } public DateTime? Completed { get; set; } } public class TodoContext : DbContext { public DbSet<Todo> Todos { get; set; } } }
- Build the solution
- Add an MVC controller with read/write actions and views, using Entity Framework. Choose the Todo and TodoContext classes. (Right click controllers in solution explorer)
- Add a reference to the Todo.Core project
- Modify the
Core.TodoView
class to include the Due and Completed fields - In the generated controller, replace the TodoContext field with the following:
IEngine<TodoModel> engine = Engine.For<TodoModel>();
- Change the model type of all the generated views from
Todo
toTodoView
- Make all the controller methods work, modifying the core library and views as needed.