Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8201945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:59:28+00:00 2026-06-07T06:59:28+00:00

I am practicing Entity Framework. I am practicing Asp.net MVC framework using Razor Engine

  • 0

I am practicing Entity Framework. I am practicing Asp.net MVC framework using Razor Engine and EF Code First. In practicing it, I found to have few problems. The problem is the Entity Framework doesnt creates a database in my SQL.
I am using VisualStudio 2011 Beta Version with MSSQL 2008. I dont know what the problem is.
Help required. Below is my Code :

    Person.cs

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;

namespace MvcDemo.Data
{
    public class Person
    {
        [Key]
        public int PersonID { get; set; }

        [Required]
        [StringLength(40)]
        public string FirstName { get; set; }

        [Required]
        [StringLength(30)]
        public int LastName { get; set; }

        public int? Age { get; set; }

        [ForeignKey("PrefixID")]
        public Prefix Prefix { get; set; }


        [Required]
        public int PrefixID { get; set; }

    }
}

    Prefix.cs

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;

namespace MvcDemo.Data
{
    public class Prefix
    {
        public int PrefixID { get; set; }

        [Required]
        [StringLength(20)]
        public string PrefixName { get; set; }
    }
}

MvcContext.cs

using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using MvcDemo.Data;


namespace MvcDemo.DataAccess
{
    public class MvcContext : DbContext
    {
        public MvcContext()
            : base("name = MvcDemoApp")
        {
        }
        public DbSet<Person> People { get; set; }

        public DbSet<MvcDemo.Data.Prefix> Prefix { get; set; }

    }
}

ConnectionString:
<connectionStrings>
    <add name="MvcDemoApp" 
         connectionString="Server=.;Initial Catalog=MvcDemoApp;Integrated Security=true" 
  providerName="System.Data.SqlClient" />
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T06:59:29+00:00Added an answer on June 7, 2026 at 6:59 am

    If this is all of your code it is not surprising that a database is not created. There is no code that executes commands against the database. As soon as you start iterating over e.g. MvcContext.People or do some insert you will notice that the database gets created.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whilst practicing some TDD at work for an ASP.Net MVC project, I ran into
For practicing purposes, I’m about to create a new ASP.NET MVC 3.0 application. My
I am practicing these problems: http://code.google.com/codejam/contest/32016/dashboard#s=p1&a=1 I believe I have the correct solution, (even
I have been practicing some old C++ problems to prepare for a few job
Im practicing with one way hash encryption. I have a MVC model with Entity
I am practicing with Python using Pyramid framework. I created a py, myfuncs.py ,
I was practicing some programming problems and tried to code the popular reverse words
I have been practicing TDD and (some) XP for a few years now and
I'm practicing writing MVC applications. I have a Mastermind game, that I would like
While practicing a tutorial on GTK+ I have encountered sample code that looks like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.