You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
977 B
35 lines
977 B
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace CockRoachDBEFCoreTest
|
|
{
|
|
public class Program
|
|
{
|
|
private static void Main(string[] args)
|
|
{
|
|
using var db = new MyDbContext();
|
|
if (db.Database.EnsureCreated())
|
|
{
|
|
var user = new User
|
|
{
|
|
Name = "admin",
|
|
UserRoles = new List<UserRole> {
|
|
new UserRole{
|
|
Role=new Role{
|
|
Name="管理员"
|
|
}
|
|
}
|
|
}
|
|
};
|
|
db.Set<User>().Add(user);
|
|
db.SaveChanges();
|
|
}
|
|
foreach (var item in db.Set<User>())
|
|
{
|
|
Console.WriteLine($"id:{item.Id},name:{item.Name}");
|
|
}
|
|
Console.WriteLine(db.Set<User>().Count());
|
|
}
|
|
}
|
|
} |