EF 6 + EF.Reverse.POCO.Generator mdf not initialized

In this code, I used two approaches to generating POCOS, each in its own projects. One with the EF 6 designer, the other with the first Entity Framework Poco Code generator. Then I create an initializer that extends DropCreateDatabaseAlwayswith almost the same methods Seed()(naming conventions are different). Then I created a test project for each of them, with one test method, for example:

    public void TestMethod1()
    {
        System.Data.Entity.Database.SetInitializer(new PocoLagaInitializer());

        using (var context = new LagaModelDbContext())
        {
            var threadList = context.LoggerThreads.ToList();
            Assert.AreEqual(threadList.Count, 1);
        }

    }

Connection strings are the same in all projects .:

<add name="LagaModel"
             providerName="System.Data.SqlClient"
            connectionString="Data Source=(LocalDB)\v11.0;AttachDbFileName=|DataDirectory|\LagaDatabase.mdf;Initial Catalog=Logging;Integrated Security=True;MultipleActiveResultSets=True" />

EF6 constructor code creates a file, POCO generator errors:

System.Data.SqlClient.SqlException: Cannot attach file 'D: \\ bin \ Debug \ LagaDatabase.mdf' as the Registration database.

Does anyone know what this difference is?

+4

Source: https://habr.com/ru/post/1605858/


All Articles