Click here to Skip to main content
11,576,293 members (61,822 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET MVC
Hey!

I've created a DB with code first EF and later deleted the DB. Now again I want to create, but when i run project the DB is not created. I think there might be a problem with the settings. What do I need add in settings. here's my code:

public class EFDbContext : DbContext
    {
        public DbSet<Advert> Adverts { get; set; }
        public DbSet<Kind> Kinds { get; set; }
        public DbSet<Age> Ages { get; set; }
        public DbSet<Castration> Castrations { get; set; }
        public DbSet<Coloring> Colorings { get; set; }
        public DbSet<Color> Colors { get; set; }
        public DbSet<Hair> Hair { get; set; }
        public DbSet<Pet> Pets { get; set; }
        public DbSet<Sex> Sexes { get; set; }
        
    }

<connectionStrings>
    <add name="EFDbContext" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=SearchPets;Integrated Security=True"
          providerName="System.Data.SqlClient"/>
  </connectionStrings>

Thanks in advance

P.S. Sorry for my bad english
Posted 1-Feb-13 2:56am
DimiBy134
Edited 2-Feb-13 19:14pm
v2
Comments
sjelen at 1-Feb-13 9:08am
   
check if any errors are reported by sql server.
Since you use integrated security, it's possible that account you're running from does not have privilege to create database.

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 271
1 F-ES Sitecore 140
2 Abhinav S 135
3 Lucifier Rocks 105
4 Dave Kreskowiak 80
0 OriginalGriff 705
1 Sergey Alexandrovich Kryukov 626
2 Abhinav S 483
3 F-ES Sitecore 410
4 Suvendu Shekhar Giri 365


Advertise | Privacy | Mobile
Web04 | 2.8.150603.1 | Last Updated 3 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100