Form ASP.NET MVC 5 cannot access model properties

I'm starting on ASP.NET MVC, following tutorials and handouts on the internet I created a study project and I am having some doubts.

Well, first I will create a following class structure:

> Acesso -> Possui informações de identificacao(Login e Senha) 
> Nivel_Acesso -> Define o nível de acesso de um determinado "ACESSO"
> Cliente -> Guarda os dados do cliente e possui Acesso e Endereco
> Endereco -> Armazena Endereco do cliente

I created a class of type Context that maps all these entities, as well as a controler responsible for logging in and viewing this controler. The problem is precisely in this login view, because when I try to declare the model at the top of the document " Login.cshtml "the model does not appear to be being "viewed" from the view. I say this, because when inserting the line - > @ Model "Project Name (end point)" it does not display the project directories.

And when I try to access some property of the model, it looks like the object is empty.

Follows screen:

insert the description of the image here

The other doubt is related to the entity-framework, as it seems to have worked normally when creating the bank for the first time, however I ended up dropping the DB. Now when I start the project, the bank is not created again by the entity-framework. I even tried to create a Migration and give update-Database, but it did not have an effect on the bank.

Author: Cleiton Ribeiro, 2014-10-24

1 answers

Your problem is in how you declare the type of View.

A type must be declared with @model, and not with @Model, i.e. model in lowercase.

For use you should use model

Example:

@model ProjetoWeb.Models.Cliente

@if (Model != null)
{
   @*realiza um processo*@
}
 2
Author: , 2014-10-24 12:51:00