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

27 lines
666 B
C#
Raw Normal View History

using Bunny.Common.EFCore;
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.BlogId)
.First();
Console.WriteLine(blog.Url);
}
}