I'm new to entity and I'm following a step-by-step guide to creating a Code First ( link ) .
I created the application, debugged it and it runs perfectly without any errors, however no bank is created ... The main code follows the App.config:
I think it's some configuration problem or something ... Anyone more experienced has an idea of what it can be?
static void Main(string[] args)
{
using (var ctx = new SchoolContext())
{
Student stud = new Student() { StudentName = "New Student" };
try
{
ctx.Students.Add(stud);
ctx.SaveChanges();
}catch(Exception ex)
{
Console.WriteLine(ex);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit
http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework"
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,
EntityFramework, Version=6.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="entityFramework" connectionString="Server=localhost\SQLEXPRESS;Database=master;Trusted_Connection=True;" providerName="System.Data.SqlClient" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>