हम ईएफ 5 (लोकलबीबी) \ v11.0 (Vstudio 2012) पर कोड-प्रथम माइग्रेशन का उपयोग कर रहे हैं और सबकुछ अब तक अच्छी तरह से काम कर चुका है।स्पष्ट माइग्रेशन (ईएफ 5) (माइग्रेशन लंबित) उत्पन्न करने में असमर्थ
हालांकि - आज मुझे कुछ तालिकाओं पर कुछ इंडेक्स बनाने की आवश्यकता है और समस्याओं में भाग गया।
सबसे पहले मैं प्रधानमंत्री में ऐसा किया: मैं डेटाबेस अद्यतन और परिणाम यह था
public override void Up()
{
Sql(@"CREATE NONCLUSTERED INDEX [idx_WtgId_StartDateTime_EndDateTime] ON [dbo].[Outages]
(
[WtgId] ASC,
[StartDateTime] ASC,
[EndDateTime] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]");
}
:
PM> update-database -startupprojectname D3A.Data -force -verbose
Using StartUp project 'D3A.Data'.
Using NuGet project 'D3A.Data'.
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Target database is: 'D3A.Data.StorageContext' (DataSource: (localdb)\v11.0, Provider: System.Data.SqlClient, Origin: Convention).
Applying code-based migrations: [201310301258520_AddIdxToOutage].
Applying code-based migration: 201310301258520_AddIdxToOutage.
CREATE NONCLUSTERED INDEX [idx_WtgId_StartDateTime_EndDateTime] ON [dbo].[Outages]
(
[WtgId] ASC,
[StartDateTime] ASC,
[EndDateTime] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
[Inserting migration history record]
Running Seed method.
PM> add-migration AddIdxToOutage
Scaffolding migration 'AddIdxToOutage'.
मैं करने के लिए scaffolded प्रवास में कोड को संशोधित किया
आईडीएक्स तालिका पर बनाया गया था और सभी खुश थे।
हालांकि - जब मैंने अगली अनुक्रमणिका बनाई, तो मैं समस्याओं में भाग गया। लेकिन WT * - मैं के रूप में
PM> add-migration AddIdxToState
Unable to generate an explicit migration because the following explicit migrations are pending: [201310301258520_AddIdxToOutage]. Apply the pending explicit migrations before attempting to generate a new explicit migration.
क्षमा मेरी फ्रेंच एक खाली प्रवास कार्य बनाया?
इस के आसपास कोई रास्ता नहीं लगता है। मैं पहले idx के अलावा माइग्रेशन चरण पर वापस जा सकता हूं, idx'es को फिर से जोड़ सकता हूं और वही बात फिर से होती है।
क्या आप मुझे बता सकते हैं कि मैं यहां क्या खो रहा हूं? मैं क्या गलत कर रहा हूं?
संपादित करें:
मैं शुरू में सोचा था कि मेरी परेशानी डेटाबेस/localdb के खिलाफ कच्चे एसक्यूएल को क्रियान्वित किया गया था, लेकिन यह सब कुछ अब मैं क्या की तरह लगता है पहले ऐड-माइग्रेशन के बाद बंद हो जाता है।
मैं सिर्फ डेटाबेस के लिए एक नई तालिका जोड़ा गया है और यह प्रधानमंत्री कंसोल से एसटीडी-आउट परिणाम है:
PM> add-migration AddMyLoggerTable
Scaffolding migration 'AddMyLoggerTable'.
The Designer Code for this migration file includes a snapshot of your current Code First model. This snapshot is used to calculate the changes to your model when you scaffold the next migration. If you make additional changes to your model that you want to include in this migration, then you can re-scaffold it by running 'Add-Migration 201310301419063_AddMyLoggerTable' again.
PM> update-database -startupproject DongEnergy.D3A.Data -verbose
Using StartUp project 'D3A.Data'.
Using NuGet project 'D3A.Data'.
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Target database is: 'D3A.Data.StorageContext' (DataSource: (localdb)\v11.0, Provider: System.Data.SqlClient, Origin: Convention).
Applying code-based migrations: [201310301419063_AddMyLoggerTable].
Applying code-based migration: 201310301419063_AddMyLoggerTable.
CREATE TABLE [dbo].[MyLoggerTable] (
[id] [int] NOT NULL,
[functionId] [int],
[elapsedTime] [bigint],
[noOfRecords] [int],
[dateCreated] [datetime] DEFAULT getDate()
)
[Inserting migration history record]
Running Seed method.
PM> add-migration AddMyLoggerTableFunction
Unable to generate an explicit migration because the following explicit migrations are pending: [201310301419063_AddMyLoggerTable]. Apply the pending explicit migrations before attempting to generate a new explicit migration.
सूचना कैसे मैं एक नया, रिक्त प्रवास कार्य जोड़ने, createTable-विधि का उपयोग करें और है जो डेटाबेस में सफलतापूर्वक अपडेट किया गया। लेकिन जब मैं एक नया माइग्रेशन चरण जोड़ता हूं, तो यह शिकायत करता है कि डेटाबेस के लिए "प्रतिबद्ध" कार्य अभी भी "लंबित" है - भले ही माइग्रेशन इतिहास और डेटाबेस ऑब्जेक्ट्स दोनों अपडेट किए गए हों।
प्रयास करें:, वापस लाएं अपना माइग्रेशन हटाएँ और इसे पुन:। मुझे कुछ समय "रिक्त" माइग्रेशन के साथ समस्या थी लेकिन उस सरल चाल ने हमेशा ऐसा किया। –
@allo_man, ठीक है, मैंने कोशिश की। मैं माइग्रेशन चरण/पहले/इंडेक्स-निर्माण पर वापस लौट आया। यह ठीक काम किया। फिर मैंने इंडेक्स बनाने के लिए पहला कदम जोड़ा। यह ठीक काम करता है और अद्यतन-डेटाबेस काम करता है जैसे इरादा। जब मैं दूसरी अनुक्रमणिका बनाने के लिए माइग्रेशन जोड़ता हूं, तो यह विफल हो जाता है। –
आपके पहले माइग्रेशन __MigrationHistory तालिका में उसकी प्रविष्टि में बनाया है? – Adrian