我想在EF-Core中创建sqlite函数,特别是newid(),并使用现有的与SQLServer兼容的c#代码(使用DbContext)来使用它们。
创建实体时,EF-Core会在dbcontext.SaveChanges()之后调用newid()函数。
我能够使用新的SQLiteConnection创建函数
var connection = new SQLiteConnection(connectionString);
connection.CreateFunction("newid", () => Guid.NewGuid());
但这些内容既不会持久化,也不会被DbContext调用。
[DbFunction]属性看起来很有前途,但我无法让它与SQLite数据库一起工作。
1条答案
按热度按时间pgccezyw1#