Hello, I would like to create database with "code first" approach in Entity Framework. However, even if I don't get any exceptions, database is not created. What may be the reason for that? app.config <connectionStrings> <add name="CodeFirstDatabase" providerName="System.Data.SqlClient" connectionString="Server=.\SQLEXPRESS;Database=MT4Analyzer;Trusted_Connection=true;"/> </connectionStrings> Code (markup): Database.cs public class EntityData : DbContext { // DbContext required: C:\Program Files (x86)\Microsoft Web Tools\Packages\EntityFramework.5.0.0\lib\net40\EntityFramework.dll public List<EntityStringColumn> EntityStringColumns { get; set; } public List<EntityDoubleColumn> EntityDoubleColumns { get; set; } public EntityData() { EntityStringColumns = new List<EntityStringColumn>(); EntityDoubleColumns = new List<EntityDoubleColumn>(); } } Code (markup): TheOtherFile.cs // Here currentDBRow has all values that I want to add to DB. using (var db = currentDBRow) { var result = db.SaveChanges(); } Code (markup): Variable 'result' has value 0 and database is not created. I can log to SQL Server with Management Studio as current user or as "sa" (however "sa" requires password) because "Mixed Mode" is enabled. Regards!
if your using a SQLClient Data Context provider, You'll need to explicitly create the database from the context constructor somewhere
Wren11 is absolutely right as it is very important to create your database explicitly if you are using SQLClient data context provider.