In Entity Framework Code First method, update-database command does nothing
I had a working project with a .mdf database.
I removed this database and migrations and added them again. Now update-database command does nothing.
This is the output of update-database command:
PM> Update-Database -v
Using StartUp project 'TrackingTest'.
Using NuGet project 'TrackingTest'.
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Target database is: '' (DataSource: (LocalDB)MSSQLLocalDB, Provider: System.Data.SqlClient, Origin: Configuration).
No pending explicit migrations.
Applying automatic migration: 201811170653301_AutomaticMigration.
CREATE TABLE [dbo].[BatchToLists] (
[Id] [int] NOT NULL IDENTITY,
[InputBatch_Id] [int],
[OutputList_Id] [int],
CONSTRAINT [PK_dbo.BatchToLists] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[InputBatches] (
[Id] [int] NOT NULL IDENTITY,
[Producer_Id] [int],
[ProductType_Id] [int],
CONSTRAINT [PK_dbo.InputBatches] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[Producers] (
[Id] [int] NOT NULL IDENTITY,
[Title] [nvarchar](max),
CONSTRAINT [PK_dbo.Producers] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[OutputLists] (
[Id] [int] NOT NULL IDENTITY,
CONSTRAINT [PK_dbo.OutputLists] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[ProductTypes] (
[Id] [int] NOT NULL IDENTITY,
[Title] [nvarchar](max),
CONSTRAINT [PK_dbo.ProductTypes] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_InputBatch_Id] ON [dbo].[BatchToLists]([InputBatch_Id])
CREATE INDEX [IX_OutputList_Id] ON [dbo].[BatchToLists]([OutputList_Id])
CREATE INDEX [IX_Producer_Id] ON [dbo].[InputBatches]([Producer_Id])
CREATE INDEX [IX_ProductType_Id] ON [dbo].[InputBatches]([ProductType_Id])
ALTER TABLE [dbo].[BatchToLists] ADD CONSTRAINT [FK_dbo.BatchToLists_dbo.InputBatches_InputBatch_Id] FOREIGN KEY ([InputBatch_Id]) REFERENCES [dbo].[InputBatches] ([Id])
ALTER TABLE [dbo].[BatchToLists] ADD CONSTRAINT [FK_dbo.BatchToLists_dbo.OutputLists_OutputList_Id] FOREIGN KEY ([OutputList_Id]) REFERENCES [dbo].[OutputLists] ([Id])
ALTER TABLE [dbo].[InputBatches] ADD CONSTRAINT [FK_dbo.InputBatches_dbo.Producers_Producer_Id] FOREIGN KEY ([Producer_Id]) REFERENCES [dbo].[Producers] ([Id])
ALTER TABLE [dbo].[InputBatches] ADD CONSTRAINT [FK_dbo.InputBatches_dbo.ProductTypes_ProductType_Id] FOREIGN KEY ([ProductType_Id]) REFERENCES [dbo].[ProductTypes] ([Id])
CREATE TABLE [dbo].[__MigrationHistory] (
[MigrationId] [nvarchar](150) NOT NULL,
[ContextKey] [nvarchar](300) NOT NULL,
[Model] [varbinary](max) NOT NULL,
[ProductVersion] [nvarchar](32) NOT NULL,
CONSTRAINT [PK_dbo.__MigrationHistory] PRIMARY KEY ([MigrationId], [ContextKey])
)
INSERT [dbo].[__MigrationHistory]([MigrationId], [ContextKey], [Model], [ProductVersion])
VALUES (N'201811170653301_AutomaticMigration', N'TrackingTest.Migrations.Configuration', 0x1F8B0800000000000400ED5B4B6FE33610BE17E87F10746A8BAC95642F6D60EF62D79B1441370FC4CEA2B780916847A844B922152428FACB7AE84FEA5FE8E84DF1A58795ACB3087CB125CE701E1F39C3E1F8BF7FFE9DBE7F0803EB1EC7D48FC8CC3E98ECDB16266EE4F9643DB313B67AF3B3FDFEDDF7DF4D8FBDF0C1FA528E7B9B8E034A4267F61D639B23C7A1EE1D0E119D84BE1B47345AB1891B850EF222E7707FFF17E7E0C0C1C0C2065E9635BD4A08F3439CFD809FF388B878C312149C451E0E68F11CDE2C32AED6390A31DD2017CFEC658CDC3F40BA25A6CCB63E043E0219163858D91622246288818447D7142F581C91F562030F50B07CDC6018B74201C585E447F5F0AE4AEC1FA64A383561C9CA4D288BC29E0C0FDE16567144F241B6B52BAB81DD8EC1BEEC31D53AB3DDCCFE88987BB78C3EFBA9D5C4F98EE6419C8E6D5A77C2D1EC59FC9BBD0A090098F4B367CD938025319E119CB018057BD665721BF8EE6FF87119FD81C98C2441C04B0832C2BBC603787419471B1CB3C72BBC2AE43EF56CCB69D239226145C6D1E4EA9C12F6F6D0B6CE6172741BE00A009CEA0B16C5F8574C708C18F62E11633826290F9C99509AFD1CDDFBEB8C549C956C129699CCB6AE70900DA177FE2647276FCC1B7EE8491C855751D0741137E2661125B10B322F23E3B0258AD7987517F72261409BE3A1455C7EA85ADC7A84515C6E984ADCA953C3D60866DE7E1DB15C93BC42B9151BF0D34B5C1C2B9151BEBCC9BF30CA83427A5939BAC4833CA244CC2028D4A276044249F00A03CD5C4B9F05B89C0E822858C8B6CED0C3674CD6EC6E66C357F0B8FF80BDF24921C235F1217100221627B82FD852186D0F3671F3D1C37110D8F88DB023DC6A9257C00D59D92C7DD273716734AFE67E39EB3B7398618937DF6B56B930A8CF42FF4069E4FA996C4258A9856A6A7B4C3CAB7513CA2DCC6F636068409DBF019C8118337B7F3239902C69E25D45D39A379F0C35B9FF246ACFE969565F93ACEAE46CCB5C6B611BC710A3B45D26E8650DD9D6030DC245812EF2AA72E3510DA2C8AAB909F89835A241940BD78C63DD2A169749B1E50F58299A2D60D4C592EF20F38830E4C316DC344756BE5044AB6B8A8B80458BED53542465BAC04C861B6C87F5A6A5028D649326AB5A63AC62C51BA48553B91BA9D8D41B5C0B931A8E2A363C583B49536045234FF156E0C43956568E8B42DC386D362AA6035DE242A549C3A44E1F5625B239564D3F8B094853E70EF6D0952B64A37489157DA205A7537319182CD4121F9EC74C3C78CD66D245903E31645B3329A206C7B2B14CB7B6923ACBD3AD2F5350E91E56A455A6DC0CBA0791ED3154669F55ECA8CBDC4E5EE72EEBE18EA6203E3D439B0DE4EB5C81BC78622DF2EAF8FCCDA27FF138CC79382E55D4902B69AB99E0F881D658780B5383A4277E4CD927C4D02D4A4F0C732F94863522A5668B2FA7520443D97BE5CE5F12A5DF8B938EA6982D32A9CD78029A85708CCA94C4EA25265367F7142840B1E254378F822424BA9361EE6D6172514547D251409C68B74E566D8078B055F51B7E07A39A885FA44DEB703ED8A05522D5DF9C7AD2ED8CA9A32E0A093C83E2D1CE38840F63835DA28FD61D9C62227EC118CF83E996285732E90C740DF5B78FF56682A1DE81B834AB65A3E14676DF9FD3A4497367246562B27D3AF9A7E2A772546AA24A8021B21559DD40D97A8B04F98FE767D593539A9676AB9A6A478DC5ACB2372E74C7B9F664A931BC475AA47083F99436D41735A31190623E9BEE145C8C8A8F0A18FE60DB0130FCF0F100239F57077A8363343260E453FA4E01C6A8F8D680519FF1DBE3FFB8F1475D0CD82A04E52C478B42EAF2C24E01C5AC773B52A4428738A4CA90AA828750D898164586F67640A9EA900FB12D50E2DEF7D28AC3E291321C4ED20193C59FC13CF02127AB079C21E2AF0094F9ADAF7DB87F7028F415EE4E8F9F43A917288A349A46BFA6DF9EE1F6DA27E59E6FBA9F962EB7CD17D642A0E36692EE594E89871F66F65F19E59175FAFB4D8378CFBA88C1E347D6BEF5372F86F2425B9042D83DFB49D120EE2EC59086B86FC3E78D5CB89FAD39D26DFC2D6E82438428A99FC0E3EA62CF8BF577A32985DCA3D8BD43F10F217AF871247B692FED5F86C506754DBD44459F1E1A6334FB8CD1DC231EC3FB76280033F01B8E53B3A200722DCA62C8B6A46AD365EC13D7DFA040D441CE39BBE021356CC5527CF3096F30491D2DEBD865B6969A4FC55D00689B199EAEF1A9B70F5B30D168EC18DA253408153D3DB5252ECC97718AE9DA8A3CCF0C8D0E2D6062D164403BD68E40C378FFF1D5A1D15ACE7906680C6D861BA9F9EDEB4612DD2DCE6E041353F5667464A87B03E5C608D191DAE6BFB6DEBFBCD831B3BDDB085C9F6742A66E204377604B6FA06A26631F8CAE7BD0D83CA89A45DB2367E82D6C692D544D63EA78DAA2F750AF5136409EEB79BB1395DD88C62629193162AD76A79B0F7B8BAF0FC29A6B8D9D6E2A949788D8A5F0F5D57FFA6EC141DD816302BF472BA05C098700C5FD7D1EC224F5D7358BB4C44FB0DB084DD59853B28ACA482948540E114EDF6798210FE2D68798F92BE43278ED624AB33F0D7D414102438EC35BEC9D921C43A0320E6F83C6BF90D2486B9A3FEB776CCA3CBDD864FF141A430510D30715F005F998F88157C97DA228B36858A421BC2869A4BE64696963FD58713A8F48474685F9AACC6389C34D00CCE80559A07B3C44B66B8A3FE335721FCB0B0D3D93764734CD3EFDE4A3758C425AF0A8E9E12760D80B1FDEFD0F941AC6B945420000 , N'6.2.0-61023')
Running Seed method.
And this is my connection string in app.config file:
<add name="TrackingTest" connectionString="Data Source=(LocalDB)MSSQLLocalDB;AttachDbFilename=|DataDirectory|Warehouse.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
But there is not any table in the database!
UPDATE
The application executes normally. Then the tables should be there. But Server Explorer does not show them!
vb.net visual-studio-2017 entity-framework-6
add a comment |
I had a working project with a .mdf database.
I removed this database and migrations and added them again. Now update-database command does nothing.
This is the output of update-database command:
PM> Update-Database -v
Using StartUp project 'TrackingTest'.
Using NuGet project 'TrackingTest'.
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Target database is: '' (DataSource: (LocalDB)MSSQLLocalDB, Provider: System.Data.SqlClient, Origin: Configuration).
No pending explicit migrations.
Applying automatic migration: 201811170653301_AutomaticMigration.
CREATE TABLE [dbo].[BatchToLists] (
[Id] [int] NOT NULL IDENTITY,
[InputBatch_Id] [int],
[OutputList_Id] [int],
CONSTRAINT [PK_dbo.BatchToLists] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[InputBatches] (
[Id] [int] NOT NULL IDENTITY,
[Producer_Id] [int],
[ProductType_Id] [int],
CONSTRAINT [PK_dbo.InputBatches] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[Producers] (
[Id] [int] NOT NULL IDENTITY,
[Title] [nvarchar](max),
CONSTRAINT [PK_dbo.Producers] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[OutputLists] (
[Id] [int] NOT NULL IDENTITY,
CONSTRAINT [PK_dbo.OutputLists] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[ProductTypes] (
[Id] [int] NOT NULL IDENTITY,
[Title] [nvarchar](max),
CONSTRAINT [PK_dbo.ProductTypes] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_InputBatch_Id] ON [dbo].[BatchToLists]([InputBatch_Id])
CREATE INDEX [IX_OutputList_Id] ON [dbo].[BatchToLists]([OutputList_Id])
CREATE INDEX [IX_Producer_Id] ON [dbo].[InputBatches]([Producer_Id])
CREATE INDEX [IX_ProductType_Id] ON [dbo].[InputBatches]([ProductType_Id])
ALTER TABLE [dbo].[BatchToLists] ADD CONSTRAINT [FK_dbo.BatchToLists_dbo.InputBatches_InputBatch_Id] FOREIGN KEY ([InputBatch_Id]) REFERENCES [dbo].[InputBatches] ([Id])
ALTER TABLE [dbo].[BatchToLists] ADD CONSTRAINT [FK_dbo.BatchToLists_dbo.OutputLists_OutputList_Id] FOREIGN KEY ([OutputList_Id]) REFERENCES [dbo].[OutputLists] ([Id])
ALTER TABLE [dbo].[InputBatches] ADD CONSTRAINT [FK_dbo.InputBatches_dbo.Producers_Producer_Id] FOREIGN KEY ([Producer_Id]) REFERENCES [dbo].[Producers] ([Id])
ALTER TABLE [dbo].[InputBatches] ADD CONSTRAINT [FK_dbo.InputBatches_dbo.ProductTypes_ProductType_Id] FOREIGN KEY ([ProductType_Id]) REFERENCES [dbo].[ProductTypes] ([Id])
CREATE TABLE [dbo].[__MigrationHistory] (
[MigrationId] [nvarchar](150) NOT NULL,
[ContextKey] [nvarchar](300) NOT NULL,
[Model] [varbinary](max) NOT NULL,
[ProductVersion] [nvarchar](32) NOT NULL,
CONSTRAINT [PK_dbo.__MigrationHistory] PRIMARY KEY ([MigrationId], [ContextKey])
)
INSERT [dbo].[__MigrationHistory]([MigrationId], [ContextKey], [Model], [ProductVersion])
VALUES (N'201811170653301_AutomaticMigration', N'TrackingTest.Migrations.Configuration', 0x1F8B0800000000000400ED5B4B6FE33610BE17E87F10746A8BAC95642F6D60EF62D79B1441370FC4CEA2B780916847A844B922152428FACB7AE84FEA5FE8E84DF1A58795ACB3087CB125CE701E1F39C3E1F8BF7FFE9DBE7F0803EB1EC7D48FC8CC3E98ECDB16266EE4F9643DB313B67AF3B3FDFEDDF7DF4D8FBDF0C1FA528E7B9B8E034A4267F61D639B23C7A1EE1D0E119D84BE1B47345AB1891B850EF222E7707FFF17E7E0C0C1C0C2065E9635BD4A08F3439CFD809FF388B878C312149C451E0E68F11CDE2C32AED6390A31DD2017CFEC658CDC3F40BA25A6CCB63E043E0219163858D91622246288818447D7142F581C91F562030F50B07CDC6018B74201C585E447F5F0AE4AEC1FA64A383561C9CA4D288BC29E0C0FDE16567144F241B6B52BAB81DD8EC1BEEC31D53AB3DDCCFE88987BB78C3EFBA9D5C4F98EE6419C8E6D5A77C2D1EC59FC9BBD0A090098F4B367CD938025319E119CB018057BD665721BF8EE6FF87119FD81C98C2441C04B0832C2BBC603787419471B1CB3C72BBC2AE43EF56CCB69D239226145C6D1E4EA9C12F6F6D0B6CE6172741BE00A009CEA0B16C5F8574C708C18F62E11633826290F9C99509AFD1CDDFBEB8C549C956C129699CCB6AE70900DA177FE2647276FCC1B7EE8491C855751D0741137E2661125B10B322F23E3B0258AD7987517F72261409BE3A1455C7EA85ADC7A84515C6E984ADCA953C3D60866DE7E1DB15C93BC42B9151BF0D34B5C1C2B9151BEBCC9BF30CA83427A5939BAC4833CA244CC2028D4A276044249F00A03CD5C4B9F05B89C0E822858C8B6CED0C3674CD6EC6E66C357F0B8FF80BDF24921C235F1217100221627B82FD852186D0F3671F3D1C37110D8F88DB023DC6A9257C00D59D92C7DD273716734AFE67E39EB3B7398618937DF6B56B930A8CF42FF4069E4FA996C4258A9856A6A7B4C3CAB7513CA2DCC6F636068409DBF019C8118337B7F3239902C69E25D45D39A379F0C35B9FF246ACFE969565F93ACEAE46CCB5C6B611BC710A3B45D26E8650DD9D6030DC245812EF2AA72E3510DA2C8AAB909F89835A241940BD78C63DD2A169749B1E50F58299A2D60D4C592EF20F38830E4C316DC344756BE5044AB6B8A8B80458BED53542465BAC04C861B6C87F5A6A5028D649326AB5A63AC62C51BA48553B91BA9D8D41B5C0B931A8E2A363C583B49536045234FF156E0C43956568E8B42DC386D362AA6035DE242A549C3A44E1F5625B239564D3F8B094853E70EF6D0952B64A37489157DA205A7537319182CD4121F9EC74C3C78CD66D245903E31645B3329A206C7B2B14CB7B6923ACBD3AD2F5350E91E56A455A6DC0CBA0791ED3154669F55ECA8CBDC4E5EE72EEBE18EA6203E3D439B0DE4EB5C81BC78622DF2EAF8FCCDA27FF138CC79382E55D4902B69AB99E0F881D658780B5383A4277E4CD927C4D02D4A4F0C732F94863522A5668B2FA7520443D97BE5CE5F12A5DF8B938EA6982D32A9CD78029A85708CCA94C4EA25265367F7142840B1E254378F822424BA9361EE6D6172514547D251409C68B74E566D8078B055F51B7E07A39A885FA44DEB703ED8A05522D5DF9C7AD2ED8CA9A32E0A093C83E2D1CE38840F63835DA28FD61D9C62227EC118CF83E996285732E90C740DF5B78FF56682A1DE81B834AB65A3E14676DF9FD3A4497367246562B27D3AF9A7E2A772546AA24A8021B21559DD40D97A8B04F98FE767D593539A9676AB9A6A478DC5ACB2372E74C7B9F664A931BC475AA47083F99436D41735A31190623E9BEE145C8C8A8F0A18FE60DB0130FCF0F100239F57077A8363343260E453FA4E01C6A8F8D680519FF1DBE3FFB8F1475D0CD82A04E52C478B42EAF2C24E01C5AC773B52A4428738A4CA90AA828750D898164586F67640A9EA900FB12D50E2DEF7D28AC3E291321C4ED20193C59FC13CF02127AB079C21E2AF0094F9ADAF7DB87F7028F415EE4E8F9F43A917288A349A46BFA6DF9EE1F6DA27E59E6FBA9F962EB7CD17D642A0E36692EE594E89871F66F65F19E59175FAFB4D8378CFBA88C1E347D6BEF5372F86F2425B9042D83DFB49D120EE2EC59086B86FC3E78D5CB89FAD39D26DFC2D6E82438428A99FC0E3EA62CF8BF577A32985DCA3D8BD43F10F217AF871247B692FED5F86C506754DBD44459F1E1A6334FB8CD1DC231EC3FB76280033F01B8E53B3A200722DCA62C8B6A46AD365EC13D7DFA040D441CE39BBE021356CC5527CF3096F30491D2DEBD865B6969A4FC55D00689B199EAEF1A9B70F5B30D168EC18DA253408153D3DB5252ECC97718AE9DA8A3CCF0C8D0E2D6062D164403BD68E40C378FFF1D5A1D15ACE7906680C6D861BA9F9EDEB4612DD2DCE6E041353F5667464A87B03E5C608D191DAE6BFB6DEBFBCD831B3BDDB085C9F6742A66E204377604B6FA06A26631F8CAE7BD0D83CA89A45DB2367E82D6C692D544D63EA78DAA2F750AF5136409EEB79BB1395DD88C62629193162AD76A79B0F7B8BAF0FC29A6B8D9D6E2A949788D8A5F0F5D57FFA6EC141DD816302BF472BA05C098700C5FD7D1EC224F5D7358BB4C44FB0DB084DD59853B28ACA482948540E114EDF6798210FE2D68798F92BE43278ED624AB33F0D7D414102438EC35BEC9D921C43A0320E6F83C6BF90D2486B9A3FEB776CCA3CBDD864FF141A430510D30715F005F998F88157C97DA228B36858A421BC2869A4BE64696963FD58713A8F48474685F9AACC6389C34D00CCE80559A07B3C44B66B8A3FE335721FCB0B0D3D93764734CD3EFDE4A3758C425AF0A8E9E12760D80B1FDEFD0F941AC6B945420000 , N'6.2.0-61023')
Running Seed method.
And this is my connection string in app.config file:
<add name="TrackingTest" connectionString="Data Source=(LocalDB)MSSQLLocalDB;AttachDbFilename=|DataDirectory|Warehouse.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
But there is not any table in the database!
UPDATE
The application executes normally. Then the tables should be there. But Server Explorer does not show them!
vb.net visual-studio-2017 entity-framework-6
add a comment |
I had a working project with a .mdf database.
I removed this database and migrations and added them again. Now update-database command does nothing.
This is the output of update-database command:
PM> Update-Database -v
Using StartUp project 'TrackingTest'.
Using NuGet project 'TrackingTest'.
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Target database is: '' (DataSource: (LocalDB)MSSQLLocalDB, Provider: System.Data.SqlClient, Origin: Configuration).
No pending explicit migrations.
Applying automatic migration: 201811170653301_AutomaticMigration.
CREATE TABLE [dbo].[BatchToLists] (
[Id] [int] NOT NULL IDENTITY,
[InputBatch_Id] [int],
[OutputList_Id] [int],
CONSTRAINT [PK_dbo.BatchToLists] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[InputBatches] (
[Id] [int] NOT NULL IDENTITY,
[Producer_Id] [int],
[ProductType_Id] [int],
CONSTRAINT [PK_dbo.InputBatches] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[Producers] (
[Id] [int] NOT NULL IDENTITY,
[Title] [nvarchar](max),
CONSTRAINT [PK_dbo.Producers] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[OutputLists] (
[Id] [int] NOT NULL IDENTITY,
CONSTRAINT [PK_dbo.OutputLists] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[ProductTypes] (
[Id] [int] NOT NULL IDENTITY,
[Title] [nvarchar](max),
CONSTRAINT [PK_dbo.ProductTypes] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_InputBatch_Id] ON [dbo].[BatchToLists]([InputBatch_Id])
CREATE INDEX [IX_OutputList_Id] ON [dbo].[BatchToLists]([OutputList_Id])
CREATE INDEX [IX_Producer_Id] ON [dbo].[InputBatches]([Producer_Id])
CREATE INDEX [IX_ProductType_Id] ON [dbo].[InputBatches]([ProductType_Id])
ALTER TABLE [dbo].[BatchToLists] ADD CONSTRAINT [FK_dbo.BatchToLists_dbo.InputBatches_InputBatch_Id] FOREIGN KEY ([InputBatch_Id]) REFERENCES [dbo].[InputBatches] ([Id])
ALTER TABLE [dbo].[BatchToLists] ADD CONSTRAINT [FK_dbo.BatchToLists_dbo.OutputLists_OutputList_Id] FOREIGN KEY ([OutputList_Id]) REFERENCES [dbo].[OutputLists] ([Id])
ALTER TABLE [dbo].[InputBatches] ADD CONSTRAINT [FK_dbo.InputBatches_dbo.Producers_Producer_Id] FOREIGN KEY ([Producer_Id]) REFERENCES [dbo].[Producers] ([Id])
ALTER TABLE [dbo].[InputBatches] ADD CONSTRAINT [FK_dbo.InputBatches_dbo.ProductTypes_ProductType_Id] FOREIGN KEY ([ProductType_Id]) REFERENCES [dbo].[ProductTypes] ([Id])
CREATE TABLE [dbo].[__MigrationHistory] (
[MigrationId] [nvarchar](150) NOT NULL,
[ContextKey] [nvarchar](300) NOT NULL,
[Model] [varbinary](max) NOT NULL,
[ProductVersion] [nvarchar](32) NOT NULL,
CONSTRAINT [PK_dbo.__MigrationHistory] PRIMARY KEY ([MigrationId], [ContextKey])
)
INSERT [dbo].[__MigrationHistory]([MigrationId], [ContextKey], [Model], [ProductVersion])
VALUES (N'201811170653301_AutomaticMigration', N'TrackingTest.Migrations.Configuration', 0x1F8B0800000000000400ED5B4B6FE33610BE17E87F10746A8BAC95642F6D60EF62D79B1441370FC4CEA2B780916847A844B922152428FACB7AE84FEA5FE8E84DF1A58795ACB3087CB125CE701E1F39C3E1F8BF7FFE9DBE7F0803EB1EC7D48FC8CC3E98ECDB16266EE4F9643DB313B67AF3B3FDFEDDF7DF4D8FBDF0C1FA528E7B9B8E034A4267F61D639B23C7A1EE1D0E119D84BE1B47345AB1891B850EF222E7707FFF17E7E0C0C1C0C2065E9635BD4A08F3439CFD809FF388B878C312149C451E0E68F11CDE2C32AED6390A31DD2017CFEC658CDC3F40BA25A6CCB63E043E0219163858D91622246288818447D7142F581C91F562030F50B07CDC6018B74201C585E447F5F0AE4AEC1FA64A383561C9CA4D288BC29E0C0FDE16567144F241B6B52BAB81DD8EC1BEEC31D53AB3DDCCFE88987BB78C3EFBA9D5C4F98EE6419C8E6D5A77C2D1EC59FC9BBD0A090098F4B367CD938025319E119CB018057BD665721BF8EE6FF87119FD81C98C2441C04B0832C2BBC603787419471B1CB3C72BBC2AE43EF56CCB69D239226145C6D1E4EA9C12F6F6D0B6CE6172741BE00A009CEA0B16C5F8574C708C18F62E11633826290F9C99509AFD1CDDFBEB8C549C956C129699CCB6AE70900DA177FE2647276FCC1B7EE8491C855751D0741137E2661125B10B322F23E3B0258AD7987517F72261409BE3A1455C7EA85ADC7A84515C6E984ADCA953C3D60866DE7E1DB15C93BC42B9151BF0D34B5C1C2B9151BEBCC9BF30CA83427A5939BAC4833CA244CC2028D4A276044249F00A03CD5C4B9F05B89C0E822858C8B6CED0C3674CD6EC6E66C357F0B8FF80BDF24921C235F1217100221627B82FD852186D0F3671F3D1C37110D8F88DB023DC6A9257C00D59D92C7DD273716734AFE67E39EB3B7398618937DF6B56B930A8CF42FF4069E4FA996C4258A9856A6A7B4C3CAB7513CA2DCC6F636068409DBF019C8118337B7F3239902C69E25D45D39A379F0C35B9FF246ACFE969565F93ACEAE46CCB5C6B611BC710A3B45D26E8650DD9D6030DC245812EF2AA72E3510DA2C8AAB909F89835A241940BD78C63DD2A169749B1E50F58299A2D60D4C592EF20F38830E4C316DC344756BE5044AB6B8A8B80458BED53542465BAC04C861B6C87F5A6A5028D649326AB5A63AC62C51BA48553B91BA9D8D41B5C0B931A8E2A363C583B49536045234FF156E0C43956568E8B42DC386D362AA6035DE242A549C3A44E1F5625B239564D3F8B094853E70EF6D0952B64A37489157DA205A7537319182CD4121F9EC74C3C78CD66D245903E31645B3329A206C7B2B14CB7B6923ACBD3AD2F5350E91E56A455A6DC0CBA0791ED3154669F55ECA8CBDC4E5EE72EEBE18EA6203E3D439B0DE4EB5C81BC78622DF2EAF8FCCDA27FF138CC79382E55D4902B69AB99E0F881D658780B5383A4277E4CD927C4D02D4A4F0C732F94863522A5668B2FA7520443D97BE5CE5F12A5DF8B938EA6982D32A9CD78029A85708CCA94C4EA25265367F7142840B1E254378F822424BA9361EE6D6172514547D251409C68B74E566D8078B055F51B7E07A39A885FA44DEB703ED8A05522D5DF9C7AD2ED8CA9A32E0A093C83E2D1CE38840F63835DA28FD61D9C62227EC118CF83E996285732E90C740DF5B78FF56682A1DE81B834AB65A3E14676DF9FD3A4497367246562B27D3AF9A7E2A772546AA24A8021B21559DD40D97A8B04F98FE767D593539A9676AB9A6A478DC5ACB2372E74C7B9F664A931BC475AA47083F99436D41735A31190623E9BEE145C8C8A8F0A18FE60DB0130FCF0F100239F57077A8363343260E453FA4E01C6A8F8D680519FF1DBE3FFB8F1475D0CD82A04E52C478B42EAF2C24E01C5AC773B52A4428738A4CA90AA828750D898164586F67640A9EA900FB12D50E2DEF7D28AC3E291321C4ED20193C59FC13CF02127AB079C21E2AF0094F9ADAF7DB87F7028F415EE4E8F9F43A917288A349A46BFA6DF9EE1F6DA27E59E6FBA9F962EB7CD17D642A0E36692EE594E89871F66F65F19E59175FAFB4D8378CFBA88C1E347D6BEF5372F86F2425B9042D83DFB49D120EE2EC59086B86FC3E78D5CB89FAD39D26DFC2D6E82438428A99FC0E3EA62CF8BF577A32985DCA3D8BD43F10F217AF871247B692FED5F86C506754DBD44459F1E1A6334FB8CD1DC231EC3FB76280033F01B8E53B3A200722DCA62C8B6A46AD365EC13D7DFA040D441CE39BBE021356CC5527CF3096F30491D2DEBD865B6969A4FC55D00689B199EAEF1A9B70F5B30D168EC18DA253408153D3DB5252ECC97718AE9DA8A3CCF0C8D0E2D6062D164403BD68E40C378FFF1D5A1D15ACE7906680C6D861BA9F9EDEB4612DD2DCE6E041353F5667464A87B03E5C608D191DAE6BFB6DEBFBCD831B3BDDB085C9F6742A66E204377604B6FA06A26631F8CAE7BD0D83CA89A45DB2367E82D6C692D544D63EA78DAA2F750AF5136409EEB79BB1395DD88C62629193162AD76A79B0F7B8BAF0FC29A6B8D9D6E2A949788D8A5F0F5D57FFA6EC141DD816302BF472BA05C098700C5FD7D1EC224F5D7358BB4C44FB0DB084DD59853B28ACA482948540E114EDF6798210FE2D68798F92BE43278ED624AB33F0D7D414102438EC35BEC9D921C43A0320E6F83C6BF90D2486B9A3FEB776CCA3CBDD864FF141A430510D30715F005F998F88157C97DA228B36858A421BC2869A4BE64696963FD58713A8F48474685F9AACC6389C34D00CCE80559A07B3C44B66B8A3FE335721FCB0B0D3D93764734CD3EFDE4A3758C425AF0A8E9E12760D80B1FDEFD0F941AC6B945420000 , N'6.2.0-61023')
Running Seed method.
And this is my connection string in app.config file:
<add name="TrackingTest" connectionString="Data Source=(LocalDB)MSSQLLocalDB;AttachDbFilename=|DataDirectory|Warehouse.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
But there is not any table in the database!
UPDATE
The application executes normally. Then the tables should be there. But Server Explorer does not show them!
vb.net visual-studio-2017 entity-framework-6
I had a working project with a .mdf database.
I removed this database and migrations and added them again. Now update-database command does nothing.
This is the output of update-database command:
PM> Update-Database -v
Using StartUp project 'TrackingTest'.
Using NuGet project 'TrackingTest'.
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Target database is: '' (DataSource: (LocalDB)MSSQLLocalDB, Provider: System.Data.SqlClient, Origin: Configuration).
No pending explicit migrations.
Applying automatic migration: 201811170653301_AutomaticMigration.
CREATE TABLE [dbo].[BatchToLists] (
[Id] [int] NOT NULL IDENTITY,
[InputBatch_Id] [int],
[OutputList_Id] [int],
CONSTRAINT [PK_dbo.BatchToLists] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[InputBatches] (
[Id] [int] NOT NULL IDENTITY,
[Producer_Id] [int],
[ProductType_Id] [int],
CONSTRAINT [PK_dbo.InputBatches] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[Producers] (
[Id] [int] NOT NULL IDENTITY,
[Title] [nvarchar](max),
CONSTRAINT [PK_dbo.Producers] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[OutputLists] (
[Id] [int] NOT NULL IDENTITY,
CONSTRAINT [PK_dbo.OutputLists] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[ProductTypes] (
[Id] [int] NOT NULL IDENTITY,
[Title] [nvarchar](max),
CONSTRAINT [PK_dbo.ProductTypes] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_InputBatch_Id] ON [dbo].[BatchToLists]([InputBatch_Id])
CREATE INDEX [IX_OutputList_Id] ON [dbo].[BatchToLists]([OutputList_Id])
CREATE INDEX [IX_Producer_Id] ON [dbo].[InputBatches]([Producer_Id])
CREATE INDEX [IX_ProductType_Id] ON [dbo].[InputBatches]([ProductType_Id])
ALTER TABLE [dbo].[BatchToLists] ADD CONSTRAINT [FK_dbo.BatchToLists_dbo.InputBatches_InputBatch_Id] FOREIGN KEY ([InputBatch_Id]) REFERENCES [dbo].[InputBatches] ([Id])
ALTER TABLE [dbo].[BatchToLists] ADD CONSTRAINT [FK_dbo.BatchToLists_dbo.OutputLists_OutputList_Id] FOREIGN KEY ([OutputList_Id]) REFERENCES [dbo].[OutputLists] ([Id])
ALTER TABLE [dbo].[InputBatches] ADD CONSTRAINT [FK_dbo.InputBatches_dbo.Producers_Producer_Id] FOREIGN KEY ([Producer_Id]) REFERENCES [dbo].[Producers] ([Id])
ALTER TABLE [dbo].[InputBatches] ADD CONSTRAINT [FK_dbo.InputBatches_dbo.ProductTypes_ProductType_Id] FOREIGN KEY ([ProductType_Id]) REFERENCES [dbo].[ProductTypes] ([Id])
CREATE TABLE [dbo].[__MigrationHistory] (
[MigrationId] [nvarchar](150) NOT NULL,
[ContextKey] [nvarchar](300) NOT NULL,
[Model] [varbinary](max) NOT NULL,
[ProductVersion] [nvarchar](32) NOT NULL,
CONSTRAINT [PK_dbo.__MigrationHistory] PRIMARY KEY ([MigrationId], [ContextKey])
)
INSERT [dbo].[__MigrationHistory]([MigrationId], [ContextKey], [Model], [ProductVersion])
VALUES (N'201811170653301_AutomaticMigration', N'TrackingTest.Migrations.Configuration', 0x1F8B0800000000000400ED5B4B6FE33610BE17E87F10746A8BAC95642F6D60EF62D79B1441370FC4CEA2B780916847A844B922152428FACB7AE84FEA5FE8E84DF1A58795ACB3087CB125CE701E1F39C3E1F8BF7FFE9DBE7F0803EB1EC7D48FC8CC3E98ECDB16266EE4F9643DB313B67AF3B3FDFEDDF7DF4D8FBDF0C1FA528E7B9B8E034A4267F61D639B23C7A1EE1D0E119D84BE1B47345AB1891B850EF222E7707FFF17E7E0C0C1C0C2065E9635BD4A08F3439CFD809FF388B878C312149C451E0E68F11CDE2C32AED6390A31DD2017CFEC658CDC3F40BA25A6CCB63E043E0219163858D91622246288818447D7142F581C91F562030F50B07CDC6018B74201C585E447F5F0AE4AEC1FA64A383561C9CA4D288BC29E0C0FDE16567144F241B6B52BAB81DD8EC1BEEC31D53AB3DDCCFE88987BB78C3EFBA9D5C4F98EE6419C8E6D5A77C2D1EC59FC9BBD0A090098F4B367CD938025319E119CB018057BD665721BF8EE6FF87119FD81C98C2441C04B0832C2BBC603787419471B1CB3C72BBC2AE43EF56CCB69D239226145C6D1E4EA9C12F6F6D0B6CE6172741BE00A009CEA0B16C5F8574C708C18F62E11633826290F9C99509AFD1CDDFBEB8C549C956C129699CCB6AE70900DA177FE2647276FCC1B7EE8491C855751D0741137E2661125B10B322F23E3B0258AD7987517F72261409BE3A1455C7EA85ADC7A84515C6E984ADCA953C3D60866DE7E1DB15C93BC42B9151BF0D34B5C1C2B9151BEBCC9BF30CA83427A5939BAC4833CA244CC2028D4A276044249F00A03CD5C4B9F05B89C0E822858C8B6CED0C3674CD6EC6E66C357F0B8FF80BDF24921C235F1217100221627B82FD852186D0F3671F3D1C37110D8F88DB023DC6A9257C00D59D92C7DD273716734AFE67E39EB3B7398618937DF6B56B930A8CF42FF4069E4FA996C4258A9856A6A7B4C3CAB7513CA2DCC6F636068409DBF019C8118337B7F3239902C69E25D45D39A379F0C35B9FF246ACFE969565F93ACEAE46CCB5C6B611BC710A3B45D26E8650DD9D6030DC245812EF2AA72E3510DA2C8AAB909F89835A241940BD78C63DD2A169749B1E50F58299A2D60D4C592EF20F38830E4C316DC344756BE5044AB6B8A8B80458BED53542465BAC04C861B6C87F5A6A5028D649326AB5A63AC62C51BA48553B91BA9D8D41B5C0B931A8E2A363C583B49536045234FF156E0C43956568E8B42DC386D362AA6035DE242A549C3A44E1F5625B239564D3F8B094853E70EF6D0952B64A37489157DA205A7537319182CD4121F9EC74C3C78CD66D245903E31645B3329A206C7B2B14CB7B6923ACBD3AD2F5350E91E56A455A6DC0CBA0791ED3154669F55ECA8CBDC4E5EE72EEBE18EA6203E3D439B0DE4EB5C81BC78622DF2EAF8FCCDA27FF138CC79382E55D4902B69AB99E0F881D658780B5383A4277E4CD927C4D02D4A4F0C732F94863522A5668B2FA7520443D97BE5CE5F12A5DF8B938EA6982D32A9CD78029A85708CCA94C4EA25265367F7142840B1E254378F822424BA9361EE6D6172514547D251409C68B74E566D8078B055F51B7E07A39A885FA44DEB703ED8A05522D5DF9C7AD2ED8CA9A32E0A093C83E2D1CE38840F63835DA28FD61D9C62227EC118CF83E996285732E90C740DF5B78FF56682A1DE81B834AB65A3E14676DF9FD3A4497367246562B27D3AF9A7E2A772546AA24A8021B21559DD40D97A8B04F98FE767D593539A9676AB9A6A478DC5ACB2372E74C7B9F664A931BC475AA47083F99436D41735A31190623E9BEE145C8C8A8F0A18FE60DB0130FCF0F100239F57077A8363343260E453FA4E01C6A8F8D680519FF1DBE3FFB8F1475D0CD82A04E52C478B42EAF2C24E01C5AC773B52A4428738A4CA90AA828750D898164586F67640A9EA900FB12D50E2DEF7D28AC3E291321C4ED20193C59FC13CF02127AB079C21E2AF0094F9ADAF7DB87F7028F415EE4E8F9F43A917288A349A46BFA6DF9EE1F6DA27E59E6FBA9F962EB7CD17D642A0E36692EE594E89871F66F65F19E59175FAFB4D8378CFBA88C1E347D6BEF5372F86F2425B9042D83DFB49D120EE2EC59086B86FC3E78D5CB89FAD39D26DFC2D6E82438428A99FC0E3EA62CF8BF577A32985DCA3D8BD43F10F217AF871247B692FED5F86C506754DBD44459F1E1A6334FB8CD1DC231EC3FB76280033F01B8E53B3A200722DCA62C8B6A46AD365EC13D7DFA040D441CE39BBE021356CC5527CF3096F30491D2DEBD865B6969A4FC55D00689B199EAEF1A9B70F5B30D168EC18DA253408153D3DB5252ECC97718AE9DA8A3CCF0C8D0E2D6062D164403BD68E40C378FFF1D5A1D15ACE7906680C6D861BA9F9EDEB4612DD2DCE6E041353F5667464A87B03E5C608D191DAE6BFB6DEBFBCD831B3BDDB085C9F6742A66E204377604B6FA06A26631F8CAE7BD0D83CA89A45DB2367E82D6C692D544D63EA78DAA2F750AF5136409EEB79BB1395DD88C62629193162AD76A79B0F7B8BAF0FC29A6B8D9D6E2A949788D8A5F0F5D57FFA6EC141DD816302BF472BA05C098700C5FD7D1EC224F5D7358BB4C44FB0DB084DD59853B28ACA482948540E114EDF6798210FE2D68798F92BE43278ED624AB33F0D7D414102438EC35BEC9D921C43A0320E6F83C6BF90D2486B9A3FEB776CCA3CBDD864FF141A430510D30715F005F998F88157C97DA228B36858A421BC2869A4BE64696963FD58713A8F48474685F9AACC6389C34D00CCE80559A07B3C44B66B8A3FE335721FCB0B0D3D93764734CD3EFDE4A3758C425AF0A8E9E12760D80B1FDEFD0F941AC6B945420000 , N'6.2.0-61023')
Running Seed method.
And this is my connection string in app.config file:
<add name="TrackingTest" connectionString="Data Source=(LocalDB)MSSQLLocalDB;AttachDbFilename=|DataDirectory|Warehouse.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
But there is not any table in the database!
UPDATE
The application executes normally. Then the tables should be there. But Server Explorer does not show them!
vb.net visual-studio-2017 entity-framework-6
vb.net visual-studio-2017 entity-framework-6
edited Nov 17 at 6:54
asked Nov 12 at 10:54
rostamiani
3861527
3861527
add a comment |
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53260640%2fin-entity-framework-code-first-method-update-database-command-does-nothing%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53260640%2fin-entity-framework-code-first-method-update-database-command-does-nothing%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown