Entity Framework creation of bank

0

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>
    
asked by anonymous 19.01.2018 / 01:01

1 answer

0

When I read with Entity, I create the modes, set the context class (with the DbSet), go to the VS console, and do the following: (this after installing the entity)

Enable-migrations

Add-migration Create Bank

Update-database -verbose

In this it checks the existence of a bank and compares the tables with the models, editing the bank according to changes made in the model. There is no bank, it creates.

I can not tell if this helps

    
19.01.2018 / 01:30