I have an issue with entity framework . I am using code first approaching but it is not create the database. It is throw an error with following codes in global.asax:
using (resimupDeneme.Data.DataContext db = new DataContext())
{
db.Database.CreateIfNotExists();
}
Here is my picture class :
public class foto
{
public int fotoId { get; set; }
[Required(ErrorMessage="fotoğraf yolu zorunludur")]
[DataType(DataType.ImageUrl)]
public string uzanti{ get; set; }
}
And my context class :
public class DataContext : DbContext
{
public DataContext() //i find this codes from internet for a solution for my problem but it is not worked
: base("DataContext")
{
Database.SetInitializer<DataContext>(new CreateDatabaseIfNotExists<DataContext>());
}
public DbSet<foto> fotos { get; set; }
}