के साथ SQLite मैं ईएफ के साथ फ्लाई पर एक एम्बेडेड SQLite डेटाबेस बनाने की कोशिश कर रहा हूं, हालांकि, मैं इसे काम नहीं कर सकता, डेटाबेस फ़ाइल कभी नहीं बनाई जा रही है।हाउटो: एंटीटीफ्रेमवर्क और कोड-फर्स्ट
मैं एफई 4.2 और नवीनतम संस्करण SQLite
यहाँ है कि मैं क्या है
app.config
<?xml version="1.0"?>
<configuration>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite"/>
<add name="SQLite Data Provider"
invariant="System.Data.SQLite"
description=".Net Framework Data Provider for SQLite"
type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite"/>
</DbProviderFactories>
</system.data>
<connectionStrings>
<add name="DataContext"
connectionString="Data Source=test.db;Version=3;New=True;"
providerName="System.Data.SQLite" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" />
</startup>
</configuration>
डीबी प्रारंभकर्ता (में कुछ सामग्री डाल करने के लिए)
class PageDbInitializer : DropCreateDatabaseAlways<PageDB>
{
protected override void Seed(PageDB context)
{
for (int i = 0; i < 10; i++)
{
WebPage page = new WebPage() { Name = "Page" + (i + 1) };
context.Pages.Add(page);
}
base.Seed(context);
}
}
DbContext:
class PageDB : DbContext
{
public DbSet<WebPage> Pages { get; set; }
}
और अंत में मुख्य में()
Database.SetInitializer(new PageDbInitializer());
मेरा मानना है कि मुझे याद आ रही कुछ कदम है, लेकिन उन्हें बाहर नहीं मिल रहा।
जिज्ञासा से बाहर, तुमने क्या किया? क्या आपने डिवार्ट प्रदाता का उपयोग किया है या कोई अन्य समाधान ढूंढ लिया है? –
@StellaMusik मैं समय के लिए SQLExpress का उपयोग कर समाप्त हुआ, लेकिन आप हमेशा SQLLite –
@PierlucSS के साथ एक ही समस्या का सामना कर मॉडल या डेटाबेस का उपयोग कर सकते हैं। मैं देवता का इतना उपयोग नहीं करना चाहता हूं कि यह मॉडल-पहले –