-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EntityFramework与SQLite #17
Comments
Step 1: Create a simple appliationStep 2: 引用Nuget包Microsoft.EntityFrameworkCore.SQlite,最新版本3.1.1。安装会自动安装其引用的下级包。 Step 3: Defining your ModelsCreate your models and add a new property for each of your new models (given that you want a table for each!)
Step 4: Create a context class for your database.What’s very interesting here is that the database doesn’t exist, the class SimpleDataStorage tells EF how and where to create it.
Step 5: Create the database and tables.在程序初始化的阶段调用
Step 6: Add Cats to the database!We can now access the database anywhere in code
|
查询使用语言集成查询 (LINQ) 从数据库检索实体类的实例。 有关详细信息,请参阅查询数据。
例2
加载所有数据
加载单个实体
|
保存数据使用实体类的实例在数据库中创建、删除和修改数据。 有关详细信息,请参阅保存数据。
|
删除数据
|
官方教程
https://docs.microsoft.com/zh-cn/ef/core/
https://docs.microsoft.com/zh-cn/ef/efcore-and-ef6/side-by-side
比较 EF Core 和 EF6
https://docs.microsoft.com/zh-cn/ef/efcore-and-ef6/
参考资料
https://stackoverflow.com/questions/36488461/sqlite-in-asp-net-core-with-entityframeworkcore
https://ianvink.wordpress.com/2018/04/09/asp-net-core-2-using-sqlite-as-a-light-weight-database/
sqlite查看工具
https://sqlitebrowser.org/dl/ 这个工具很好用。
The text was updated successfully, but these errors were encountered: