Scaffold-DbContext throw ArgumentNullException
I get the following exception when I try to scaffold one of our databases.
For foreign key FK_ActivityEvent_ActivityCode on table dbo.ActivityEvent, unable to find the column called UniqActivityCode on the foreign key's principal table, dbo.ActivityCode. Skipping foreign key.
For foreign key FK_Line_Line on table dbo.Line, unable to find the column called UniqLine on the foreign key's principal table, dbo.Line. Skipping foreign key.
For foreign key FK_MarketingLine_MarketingLine on table dbo.MarketingLine, unable to find the column called UniqMarketingLine on the foreign key's principal table, dbo.MarketingLine. Skipping foreign key.
System.ArgumentNullException: Value cannot be null.
Parameter name: column
at Microsoft.EntityFrameworkCore.Utilities.Check.NotNull[T](T value, String parameterName)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.GetPropertyName(DatabaseColumn column)
at System.Linq.Enumerable.SelectListIterator`2.ToArray()
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitPrimaryKey(EntityTypeBuilder builder, DatabaseTable table)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitTable(ModelBuilder modelBuilder, DatabaseTable table)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitTables(ModelBuilder modelBuilder, ICollection`1 tables)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitDatabaseModel(ModelBuilder modelBuilder, DatabaseModel databaseModel)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.Create(DatabaseModel databaseModel, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, IEnumerable`1 tables, IEnumerable`1 schemas, String namespace, String language, String contextDir, String contextName, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions)
at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_1.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Value cannot be null.
Parameter name: column
I successfully scaffolded one of our databases so I'm sure I'm using the scaffold command properly. Also, I can access the database using the connection string I entered on the Scaffold-DbContext
command.
I installed the following packages:
install-package microsoft.entityframeworkcore.sqlserver
install-package microsoft.entityframeworkcore.tools
Using .NET Core Console App 2.1 on Windows 10.
Not sure if this is related but I get the following message when I try to expand the Database Diagrams
in ssms. (I don't get this message on the other database that I successfully scaffolded)
sql-server entity-framework-core ef-database-first ef-core-2.1
add a comment |
I get the following exception when I try to scaffold one of our databases.
For foreign key FK_ActivityEvent_ActivityCode on table dbo.ActivityEvent, unable to find the column called UniqActivityCode on the foreign key's principal table, dbo.ActivityCode. Skipping foreign key.
For foreign key FK_Line_Line on table dbo.Line, unable to find the column called UniqLine on the foreign key's principal table, dbo.Line. Skipping foreign key.
For foreign key FK_MarketingLine_MarketingLine on table dbo.MarketingLine, unable to find the column called UniqMarketingLine on the foreign key's principal table, dbo.MarketingLine. Skipping foreign key.
System.ArgumentNullException: Value cannot be null.
Parameter name: column
at Microsoft.EntityFrameworkCore.Utilities.Check.NotNull[T](T value, String parameterName)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.GetPropertyName(DatabaseColumn column)
at System.Linq.Enumerable.SelectListIterator`2.ToArray()
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitPrimaryKey(EntityTypeBuilder builder, DatabaseTable table)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitTable(ModelBuilder modelBuilder, DatabaseTable table)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitTables(ModelBuilder modelBuilder, ICollection`1 tables)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitDatabaseModel(ModelBuilder modelBuilder, DatabaseModel databaseModel)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.Create(DatabaseModel databaseModel, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, IEnumerable`1 tables, IEnumerable`1 schemas, String namespace, String language, String contextDir, String contextName, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions)
at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_1.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Value cannot be null.
Parameter name: column
I successfully scaffolded one of our databases so I'm sure I'm using the scaffold command properly. Also, I can access the database using the connection string I entered on the Scaffold-DbContext
command.
I installed the following packages:
install-package microsoft.entityframeworkcore.sqlserver
install-package microsoft.entityframeworkcore.tools
Using .NET Core Console App 2.1 on Windows 10.
Not sure if this is related but I get the following message when I try to expand the Database Diagrams
in ssms. (I don't get this message on the other database that I successfully scaffolded)
sql-server entity-framework-core ef-database-first ef-core-2.1
You could consider creating theDbContext
and model classes manually. I've had similar trouble once or twice using the scaffold command so I don't use it anymore. It's less work doing it by hand than trying to figure out what's wrong.
– Wim Ombelets
Nov 16 '18 at 9:46
add a comment |
I get the following exception when I try to scaffold one of our databases.
For foreign key FK_ActivityEvent_ActivityCode on table dbo.ActivityEvent, unable to find the column called UniqActivityCode on the foreign key's principal table, dbo.ActivityCode. Skipping foreign key.
For foreign key FK_Line_Line on table dbo.Line, unable to find the column called UniqLine on the foreign key's principal table, dbo.Line. Skipping foreign key.
For foreign key FK_MarketingLine_MarketingLine on table dbo.MarketingLine, unable to find the column called UniqMarketingLine on the foreign key's principal table, dbo.MarketingLine. Skipping foreign key.
System.ArgumentNullException: Value cannot be null.
Parameter name: column
at Microsoft.EntityFrameworkCore.Utilities.Check.NotNull[T](T value, String parameterName)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.GetPropertyName(DatabaseColumn column)
at System.Linq.Enumerable.SelectListIterator`2.ToArray()
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitPrimaryKey(EntityTypeBuilder builder, DatabaseTable table)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitTable(ModelBuilder modelBuilder, DatabaseTable table)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitTables(ModelBuilder modelBuilder, ICollection`1 tables)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitDatabaseModel(ModelBuilder modelBuilder, DatabaseModel databaseModel)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.Create(DatabaseModel databaseModel, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, IEnumerable`1 tables, IEnumerable`1 schemas, String namespace, String language, String contextDir, String contextName, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions)
at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_1.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Value cannot be null.
Parameter name: column
I successfully scaffolded one of our databases so I'm sure I'm using the scaffold command properly. Also, I can access the database using the connection string I entered on the Scaffold-DbContext
command.
I installed the following packages:
install-package microsoft.entityframeworkcore.sqlserver
install-package microsoft.entityframeworkcore.tools
Using .NET Core Console App 2.1 on Windows 10.
Not sure if this is related but I get the following message when I try to expand the Database Diagrams
in ssms. (I don't get this message on the other database that I successfully scaffolded)
sql-server entity-framework-core ef-database-first ef-core-2.1
I get the following exception when I try to scaffold one of our databases.
For foreign key FK_ActivityEvent_ActivityCode on table dbo.ActivityEvent, unable to find the column called UniqActivityCode on the foreign key's principal table, dbo.ActivityCode. Skipping foreign key.
For foreign key FK_Line_Line on table dbo.Line, unable to find the column called UniqLine on the foreign key's principal table, dbo.Line. Skipping foreign key.
For foreign key FK_MarketingLine_MarketingLine on table dbo.MarketingLine, unable to find the column called UniqMarketingLine on the foreign key's principal table, dbo.MarketingLine. Skipping foreign key.
System.ArgumentNullException: Value cannot be null.
Parameter name: column
at Microsoft.EntityFrameworkCore.Utilities.Check.NotNull[T](T value, String parameterName)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.GetPropertyName(DatabaseColumn column)
at System.Linq.Enumerable.SelectListIterator`2.ToArray()
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitPrimaryKey(EntityTypeBuilder builder, DatabaseTable table)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitTable(ModelBuilder modelBuilder, DatabaseTable table)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitTables(ModelBuilder modelBuilder, ICollection`1 tables)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitDatabaseModel(ModelBuilder modelBuilder, DatabaseModel databaseModel)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.Create(DatabaseModel databaseModel, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, IEnumerable`1 tables, IEnumerable`1 schemas, String namespace, String language, String contextDir, String contextName, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions)
at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_1.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Value cannot be null.
Parameter name: column
I successfully scaffolded one of our databases so I'm sure I'm using the scaffold command properly. Also, I can access the database using the connection string I entered on the Scaffold-DbContext
command.
I installed the following packages:
install-package microsoft.entityframeworkcore.sqlserver
install-package microsoft.entityframeworkcore.tools
Using .NET Core Console App 2.1 on Windows 10.
Not sure if this is related but I get the following message when I try to expand the Database Diagrams
in ssms. (I don't get this message on the other database that I successfully scaffolded)
sql-server entity-framework-core ef-database-first ef-core-2.1
sql-server entity-framework-core ef-database-first ef-core-2.1
edited Nov 14 '18 at 20:31
Paolo Go
asked Nov 14 '18 at 20:25
Paolo GoPaolo Go
1,479622
1,479622
You could consider creating theDbContext
and model classes manually. I've had similar trouble once or twice using the scaffold command so I don't use it anymore. It's less work doing it by hand than trying to figure out what's wrong.
– Wim Ombelets
Nov 16 '18 at 9:46
add a comment |
You could consider creating theDbContext
and model classes manually. I've had similar trouble once or twice using the scaffold command so I don't use it anymore. It's less work doing it by hand than trying to figure out what's wrong.
– Wim Ombelets
Nov 16 '18 at 9:46
You could consider creating the
DbContext
and model classes manually. I've had similar trouble once or twice using the scaffold command so I don't use it anymore. It's less work doing it by hand than trying to figure out what's wrong.– Wim Ombelets
Nov 16 '18 at 9:46
You could consider creating the
DbContext
and model classes manually. I've had similar trouble once or twice using the scaffold command so I don't use it anymore. It's less work doing it by hand than trying to figure out what's wrong.– Wim Ombelets
Nov 16 '18 at 9:46
add a comment |
0
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%2f53308224%2fscaffold-dbcontext-throw-argumentnullexception%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
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.
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%2f53308224%2fscaffold-dbcontext-throw-argumentnullexception%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
You could consider creating the
DbContext
and model classes manually. I've had similar trouble once or twice using the scaffold command so I don't use it anymore. It's less work doing it by hand than trying to figure out what's wrong.– Wim Ombelets
Nov 16 '18 at 9:46