I'm trying to use entity framework with code first method, but for some reason it does not create a database for me. I suppose the problem is in my app.config configuration file. I never used entity framework before. I have read similar posts on stackoverflow, but however I cannot solve my problem. I do not get any errors during compilation, but when I open microsoft sql server I don't see my database created.
This is my app.config file. I found this code online, but I don't know what should I write inside Database attribute.
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<appSettings>
<add key="ipadress" value="127.0.0.1" />
<add key="port" value="14000" />
</appSettings>
<connectionStrings>
<add name="AVLdataContext" connectionString="Server=.\SQLEXPRESS;Database=Blogging;Integrated Security=True;" providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>
Also here is my model class:
namespace TCPserver
{
public class DataBaseModel
{
public static string LoadToDatabase(byte[] arr, string imei)
{
return ReversedBinaryReader.LoadToDatabase(arr, imei);
}
}
public class AVLdataContext : DbContext
{
public DbSet<Datas> Data { get; set; }
public DbSet<GPSelement> GPSelement { get; set; }
public DbSet<IOelement> IOelement { get; set; }
}
}
Here is my controller:
using (var db = new AVLdataContext())
{
db.Data.Add(data);
db.GPSelement.Add(data.Gps);
db.IOelement.Add(data.Io);
db.SaveChanges();
}
What am I doing wrong? I'm completely green at this.