I am trying to teach myself asp.net mvc and I am not sure how to do the right setup for the dbcontext class.
First I installed entity framework on my project. Then I created a model looking like this:
public class Post
{
public int PostId { get; set; }
public string Title { get; set; }
public string Content { get; set; }
public Post(int PostId, string Title, string Content)
{
this.PostId = PostId;
this.Title = Title;
this.Content = Content;
}
Afterwards I created a class in the Models folder, called ClassAppContext.cs and after creating it I did a enable-migrations, here is how this class looks :
public class ClassAppContext : DbContext
{
public DbSet<Post> Posts { get; set; }
}
Can someone tell me if my approach was right, and if not, what did I do wrong?
Also, how can I create the database from these classes, I though it is autogenerated, but I don't see a DB in my project.