CSharp-Single-EFCore/Bunny.Test.Until/EfCoreTest/EfCoreTest.cs

27 lines
663 B
C#

using Bunny.Common.Connect;
using Bunny.Dao.Models.System;
using NUnit.Framework;
namespace Bunny.Test.Until.EfCoreTest;
public class EfCoreTest
{
[Test]
public void TestDbConnection()
{
using var db = new EfCoreContext();
Console.WriteLine($"Database path: {db.DbPath}.");
// Create
Console.WriteLine("Inserting a new blog");
db.Add(new Blog { Url = "http://blogs.msdn.com/adonet" });
db.SaveChanges();
// Read
Console.WriteLine("Querying for a blog");
var blog = db.Blogs
.OrderBy(b => b.Id)
.First();
Console.WriteLine(blog.Url);
}
}