I am new to Entityframework.I am trying to create database using Codefirst approach of entityFramework. I have my Code in the DAL Layer here :
[Table("Category")]
public class Category
{
[Key]
public int CategoryId { get; set; }
[Required]
[Column(TypeName="varchar")]
[StringLength(200)]
public string CategoryName { get; set; }
}
public class DatabaseContext:DbContext
{
public DatabaseContext()
: base("DbConnection")
{
//Added the following but still it doesnt work
//Database.SetInitializer<DatabaseContext>(new CreateDatabaseIfNotExists<DatabaseContext>());
}
public DbSet<Category> Categories { get; set; }
}
Connection string in the App.Config file of DAL Layer
<connectionStrings>
<add name="DbConnection"
connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=dbPdtCgry;uid=admin;password=admin123;"
providerName="System.Data.SqlClient"></add>
This does not create database in Sql server management.But DbConnection Log file & mdf file is created in the the App_Data and I am able to add,update and delete data.
Am I missing any thing here??