27 lines
664 B
C#
27 lines
664 B
C#
using Bunny.Common.EFCore;
|
|
using Bunny.Dao.Entity.Blog;
|
|
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);
|
|
}
|
|
} |