ASP.NET MVC 5 Form Can not Access Model Properties

0

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

Well, first I created 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 the login and the view of this controler. The problem is exactly in this Login view, because when I try to declare the model at the top of the document "Login.cshtml" the model seems not to be "viewed" from the view. I say this because when I insert the line - > @Model "ProjectName (FINAL POINT)" it does not display the project directories.

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

Follow the screen:

The other question concerns the entity-framework, as it seems to have worked normally when creating the database for the first time, however I ended up dropping the DB. Now when the project starts, the database is not created again by the entity-framework. I even tried to create a Migration and give Update-Database, but it had no effect on the database.

    
asked by anonymous 24.10.2014 / 13:55

1 answer

2

Your problem is in the way you declare the View type .

A type must be declared with @model , and not with @Model , that is, model in lowercase.

For use you must use Model

Example:

@model ProjetoWeb.Models.Cliente

@if (Model != null)
{
   @*realiza um processo*@
}
    
24.10.2014 / 14:51