none
Entity Framwork Error while creating Pre complied views RRS feed

  • Question

  • Since i am facing perfomance problem i wanted to create precompiled views .I installed EF Power tool but when selecting "Genereate View" I am getting Error "A constructible type deriving from DbContext could not be found in the selected file" 

    I am using  System.Data.SQLite  Version 1.0.111 from Nuget package .

    Its Code first approach  and SqlLite as DB


    Entity Context class and the app.config  is as below

     public class DataBaseEntities: DbContext
           {
    
            public static string ConnectionString { get; set; }
            public DataBaseEntities()
                : base(ConnectionString?? "DicomCodeDb")
            {
    
    
            }
           
              public virtual IDbSet<DicomCode> DicomCodes { get; set; }
        }


    App.Config

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <configSections>
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
      </configSections>
      <connectionStrings>
        <add name="DicomCodeDb" connectionString="data source=D:\Tfs\IT10\Console\site\ScannerData\ScannerData.sqlite;foreign keys=true" providerName="System.Data.SQLite" />
      </connectionStrings>
      <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
      </startup>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
        <providers>
          <provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
          <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
          <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />   
    
        </providers>
      </entityFramework>
      <system.data>
        <DbProviderFactories>
          <remove invariant="System.Data.SQLite.EF6" />
          <add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
          <remove invariant="System.Data.SQLite" />
          <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
        </DbProviderFactories>
      </system.data>
    </configuration>



    • Edited by SomarajK Thursday, September 12, 2019 4:02 PM
    Thursday, September 12, 2019 11:33 AM

All replies

  • Hi SomarajK,

    About this error, here I found a similar thread maybe you can refer to.

    A constructible type deriving from DbContext could not be found in the selected file (EF Power Tools Beta 3/Visual Studio 2012)

    Regards,

    Kyle


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, September 13, 2019 6:13 AM
    Moderator
  • Hi Kyle,

    I have seen this post ,and if you see my constructor is default constructor with connection string configured in the app.config .(Actually i have searched whole net and tried what ever suggested )

    I also uninstalled Resharper as the below link says VS extensions can cause "Generate View" not to work .

    https://www.manongdao.com/article-408095.html

    But still the same issue .

    I am using VS2017 ,.net 4.7.2 , EF is 6.2 and System.Data.SQLite  Version 1.0.111 ( with Code first approach)


    Saturday, September 14, 2019 6:15 PM