我必須使用Firebird嵌入式數據庫和實體框架。我已經下載連接器,如果我使用此代碼:Firebird嵌入和EntityFramework代碼優先:設置連接字符串和提供者的正確方法是什麼?
using FirebirdSql.Data.FirebirdClient;
[...]
string exePath = Path.GetDirectoryName(
new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
FbConnectionStringBuilder fbStringBuilder = new FbConnectionStringBuilder();
fbStringBuilder.ServerType = FbServerType.Embedded;
fbStringBuilder.UserID = "SYSDBA";
fbStringBuilder.Password = "MASTERKEY";
fbStringBuilder.Dialect = 3;
fbStringBuilder.Charset = "UTF8";
fbStringBuilder.ClientLibrary = Path.Combine(exePath, "fbembed.dll");
fbStringBuilder.Database = Path.Combine(exePath, "test.fdb");
if (!File.Exists(Path.Combine(exePath, "test.fdb")))
{
FbConnection.CreateDatabase(fbStringBuilder.ToString());
}
FbConnection fbConn = new FbConnection(fbStringBuilder.ToString());
try
{
fbConn.Open();
Console.WriteLine("OK");
}
catch (Exception ex)
{
Console.WriteLine("ERROR");
Console.WriteLine(ex.Message);
Console.ReadKey();
}
finally
{
fbConn.Close();
}
一切正常。但是,當我嘗試使用該連接字符串的DbContext:
public class FirebirdEmbededExampleDbContext : DbContext
{
public FirebirdEmbededExampleDbContext(string connString) : base(connString)
{
this.Database.Connection.ConnectionString = connString;
}
public DbSet<ItemA> ItemsA { get; set; }
public DbSet<ItemB> ItemsB { get; set; }
}
它失敗消息:
Unsupported keyword: 'server type'
它看起來像EF沒有使用火鳥提供商。我應該如何使用它?