Last active
December 17, 2015 18:38
-
-
Save FernandoVezzali/5654264 to your computer and use it in GitHub Desktop.
models and commands
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 | |
Install-Package MvcScaffolding | |
public class Task | |
{ | |
[Key] | |
public int TaskId { get; set; } | |
public string Name { get; set; } | |
public string Description { get; set; } | |
public int? StatusId { get; set; } | |
[ForeignKey("StatusId")] | |
public virtual Status Status { get; set; } | |
public virtual ICollection<Note> Notes { get; set; } | |
public DateTime? CreatedOn { get; set; } | |
public DateTime? ModifiedOn { get; set; } | |
} | |
public class Status | |
{ | |
[Key] | |
public int StatusId { get; set; } | |
public string Name { get; set; } | |
} | |
public class Note | |
{ | |
[Key] | |
public int NoteId { get; set; } | |
public string Description { get; set; } | |
public int? TaskId { get; set; } | |
public DateTime? CreatedOn { get; set; } | |
public DateTime? ModifiedOn { get; set; } | |
} | |
Scaffold Controller Task -Repository | |
Scaffold Controller Status –Repository | |
RUN | |
remove TasksController constructor | |
RUN | |
got "No parameterless constructor defined for this object." | |
Install-Package unity.Mvc4 | |
at globa.asax.cs: | |
Bootstrapper.Initialise(); | |
at Bootstrapper file: | |
container.RegisterType<IController, TasksController>("Tasks"); | |
container.RegisterType<IStatusRepository, StatusRepository>(); | |
container.RegisterType<ITaskRepository, TaskRepository>(); | |
Create test project | |
add project reference at test project | |
Create a unite test instanciating status controller | |
At main project, create a mock for status repository | |
Enable-Migrations -ProjectName "MvcApplication3" -StartUpProjectName "MvcApplication3" | |
AutomaticMigrationsEnabled = true; | |
AutomaticMigrationDataLossAllowed = true; | |
Update-Database | |
Scaffold Controller Task -Repository -Force | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment