TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
secerka secerovic
NA
12
11.8k
EF 4.1 CodeFirst Database is not create!!!
Jul 31 2011 10:43 PM
Hello everyone!
I need help on my project.
I have two classes:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Classes
{
public class Blog
{
public int Id { get; set; }
public string Title { get; set; }
public string BloggerName { get; set; }
public List<Post> Posts { get; set; }
public string BlogCode
{
get { return Title.Substring(0, 1) + ":" + BloggerName.Substring(0, 1); }
}
}
public class Post
{
public int Id { get; set; }
public string Title { get; set; }
public string Content { get; set; }
public virtual Blog Blog { get; set; }
}
}
The second class is
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using Classes;
namespace DataLayer
{
public class Context:DbContext
{
public DbSet<Blog> Blogs { get; set; }
public DbSet<Post> Posts { get; set; }
}
}
Also I ConsoleApplication:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Classes;
using DataLayer;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
CreateBlog();
}
public static void CreateBlog()
{
var blog = new Blog { BloggerName = "Mahir", Title = "Entity Framework Code First" };
var db = new Context();
db.Blogs.Add(blog);
db.SaveChanges();
}
}
}
ConsoleApplication is Set as StartUp Project.
SQL server Management Studio is run.
When I run ConsoleApplication in SQL Server Management Studio should make a database.
Unfortunately it is not made.
Can we for some help to solve this problem and that the database is made?
Thanks in advance!
Reply
Answers (
1
)
How to Avoid Crystal Report Load Delay?
Join query in sql database