My models for my blog :
namespace AlexPeta_2.Models
{
public class Article
{
public int ArticleId { get; set; }
public string Title { get; set; }
public string Text { get; set; }
public char Published { get; set; }
public DateTime CreatedDate { get; set; }
public char AllowComment { get; set; }
public virtual ICollection<Tag> Tags { get; set; }
public virtual ICollection<Comment> Comments { get; set; }
}
}
namespace AlexPeta_2.Models
{
public class Comment
{
public int CommentId { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public string HomePage { get; set; }
public string Comm { get; set; }
public DateTime CreatedDate { get; set; }
}
}
namespace AlexPeta_2.Models
{
public class Tag
{
public int TagId { get; set; }
public string TagName { get; set; }
public virtual ICollection<Article> Articles { get; set; }
}
}
here are my dbsets:
public class BlogContext : DbContext
{
public DbSet<Article> Articles { get; set; }
public DbSet<Tag> Tags { get; set; }
public DbSet<Comment> Comments { get; set; }
}
here is my initializer :
public class BlogInitializer : DropCreateDatabaseIfModelChanges<BlogContext>
{
protected override void Seed(BlogContext context)
{
List<Tag> tags = new List<Tag>
{
new Tag { TagId = 1, TagName = "Javascript" },
new Tag { TagId = 2, TagName = "Bodybuilding" },
new Tag { TagId = 3, TagName = "Uncategorised" },
new Tag { TagId = 4, TagName = "CSS" },
new Tag { TagId = 5, TagName = "HTML/XHTML" },
new Tag { TagId = 6, TagName = "APEX" },
new Tag { TagId = 7, TagName = "PL/SQL" },
new Tag { TagId = 8, TagName = "Personal" },
new Tag { TagId = 9, TagName = "ASP" },
new Tag { TagId = 10, TagName = "MVC" },
new Tag { TagId = 11, TagName = "C#" },
new Tag { TagId = 12, TagName = "Snowboarding" }
};
tags.ForEach(t => context.Tags.Add(t));
context.SaveChanges();
}
}
The funny thing is : i ran the application with no Connection String in webconfig, it runs fine , i see all my tags in the controller but there is not Database file in APP_DATA ?? How come is that? or what happened?