How to enable migration in SQLite using EF

允我心安 提交于 2019-12-04 19:58:55

问题


I have stuck in problem. I am writing a code for windows desktop application and I have to use sqlite as a database. I have successfully installed system.data.sqlite and entity framework from nuget package. I have also created my DbContext class. Now problem is that as soon as I tried to run my code an exception comes whose inner message is

{"SQLite Error 1: 'no such table: TimeSheet'"}.

This means your table TimeSheet does not exist in database. Plz tell me how to create table in sqlite using entity framework or how to enable migrations.


回答1:


There are some implementations of migration for SQLite.

https://github.com/bubibubi/db2ef6migrations is based on the new EF6 migration interface but it has some restrictions. You can download it from Nuget searching for System.Data.SQLite.EF6.Migrations




回答2:


Unlike MS SQL Server, as default, the free Sqlite driver from system.data.sqlite doesn’t support Migration.So you can’t create a new database from code.You have to manually create it.

For that you can use SQLite Manager add-on for Firefox.

Here is the link : SQLite Manager

Or you can use SQL Server Compact/SQLite Toolbox where @ErikEJ suggested below.



来源:https://stackoverflow.com/questions/39247760/how-to-enable-migration-in-sqlite-using-ef

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!