Please tell me how to combine the Entity Framework and SqLite? Put SqLite in the project already through Nuget. Created a model through the constructor, but did not create the database yet. I do not know what is there and where to choose or write. So many sorts of menus, eyes run up, if you can bring someone screenshots or some article with screenshots of actions in order.
PS And it is also important for me that the program itself creates a database if it has not found it nearby.
UPD. I decided to try through code first. In fact, it may even be more convenient. : D I just did not try. There seems to be a convenient graphical constructor ... On the other hand, a lot of unnecessary files are being created there, but here there is only one file and that's it ... And then I began to look at what was in the config. Maybe you just need to set up there? Look at that now (I also connected sqlite):
<?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <!-- For more information on Entity Framework configuration, visit [url]http://go.microsoft.com/fwlink/?LinkID=237468[/url] --> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> </configSections> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> </startup> <entityFramework> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> <providers> <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> <connectionStrings> <add name="Model1" connectionString="data source=(LocalDb)\MSSQLLocalDB;initial catalog=ConsoleApplication2.Model1;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" /> </connectionStrings> <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> But this is all automatically generated. Those. for the database MS SQL will be used. And how to replace that SQLite was? I experimented, but that all the time errors, in general, I do not know how to configure.
UPD. Googled this error and seems to have found a solution:
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" /> It seems so true. The error disappeared, but another appeared when you called SaveChanges: "SQL logic error or missing database table no such table: MyEntities". I suspect that everything is simpler: the database and the table are not created stupidly. Only then the question arises: how to create them? Well, I understand MS Sql there, there is Managenent Studio, and what is for SQLite? And then it is important for me that the program itself could create a database if it did not find it !!!
UPD. Moreover, I found the CreateIfNotExists method, but it returns false ... Although, by the way, the database file is created in the program folder, but it is 0 bytes, well, plus the error is the same.