“Parameter count mismatch” error during adding Entity Framework migration under .NET Core 2.0
up vote
2
down vote
favorite
After migration of my project to .NET Core 2.0, fresh install of Visual Studio 15.5 and .NET CORE sdk 2.1.2, I am having an error when trying to add a migration using EF Core.
C:ProjectsSQLwalletSQLwallet>dotnet ef migrations add IdentityServer.
An error occurred while calling method 'BuildWebHost' on class 'Program'.
Continuing without the application service provider. Error: Parameter count mismatch.
Done. To undo this action, use 'ef migrations remove'
As a result an empty migration class is created, with empty Up() and Down() methods.
The program.cs looks like:
public class Program
{
public static IWebHost BuildWebHost(string args, string environmentName)
{...}
public static void Main(string args)
{
IWebHost host;
host = BuildWebHost(args, "Development");
Please advise. The migration worked fine while on Core 1.0. I have a IDesignTimeDbContextFactory implemented, and my DBContext class has a parameterless constructor, so it could not be the reason.
asp.net-core entity-framework-core ef-migrations asp.net-core-2.0
add a comment |
up vote
2
down vote
favorite
After migration of my project to .NET Core 2.0, fresh install of Visual Studio 15.5 and .NET CORE sdk 2.1.2, I am having an error when trying to add a migration using EF Core.
C:ProjectsSQLwalletSQLwallet>dotnet ef migrations add IdentityServer.
An error occurred while calling method 'BuildWebHost' on class 'Program'.
Continuing without the application service provider. Error: Parameter count mismatch.
Done. To undo this action, use 'ef migrations remove'
As a result an empty migration class is created, with empty Up() and Down() methods.
The program.cs looks like:
public class Program
{
public static IWebHost BuildWebHost(string args, string environmentName)
{...}
public static void Main(string args)
{
IWebHost host;
host = BuildWebHost(args, "Development");
Please advise. The migration worked fine while on Core 1.0. I have a IDesignTimeDbContextFactory implemented, and my DBContext class has a parameterless constructor, so it could not be the reason.
asp.net-core entity-framework-core ef-migrations asp.net-core-2.0
You can safely ignore the message. It will go away when issue #9076 is resolved.
– bricelam
Dec 8 '17 at 0:10
The problem is that the migration is not generating properly, it is empty.
– Glebby
Dec 8 '17 at 7:50
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
After migration of my project to .NET Core 2.0, fresh install of Visual Studio 15.5 and .NET CORE sdk 2.1.2, I am having an error when trying to add a migration using EF Core.
C:ProjectsSQLwalletSQLwallet>dotnet ef migrations add IdentityServer.
An error occurred while calling method 'BuildWebHost' on class 'Program'.
Continuing without the application service provider. Error: Parameter count mismatch.
Done. To undo this action, use 'ef migrations remove'
As a result an empty migration class is created, with empty Up() and Down() methods.
The program.cs looks like:
public class Program
{
public static IWebHost BuildWebHost(string args, string environmentName)
{...}
public static void Main(string args)
{
IWebHost host;
host = BuildWebHost(args, "Development");
Please advise. The migration worked fine while on Core 1.0. I have a IDesignTimeDbContextFactory implemented, and my DBContext class has a parameterless constructor, so it could not be the reason.
asp.net-core entity-framework-core ef-migrations asp.net-core-2.0
After migration of my project to .NET Core 2.0, fresh install of Visual Studio 15.5 and .NET CORE sdk 2.1.2, I am having an error when trying to add a migration using EF Core.
C:ProjectsSQLwalletSQLwallet>dotnet ef migrations add IdentityServer.
An error occurred while calling method 'BuildWebHost' on class 'Program'.
Continuing without the application service provider. Error: Parameter count mismatch.
Done. To undo this action, use 'ef migrations remove'
As a result an empty migration class is created, with empty Up() and Down() methods.
The program.cs looks like:
public class Program
{
public static IWebHost BuildWebHost(string args, string environmentName)
{...}
public static void Main(string args)
{
IWebHost host;
host = BuildWebHost(args, "Development");
Please advise. The migration worked fine while on Core 1.0. I have a IDesignTimeDbContextFactory implemented, and my DBContext class has a parameterless constructor, so it could not be the reason.
asp.net-core entity-framework-core ef-migrations asp.net-core-2.0
asp.net-core entity-framework-core ef-migrations asp.net-core-2.0
edited Dec 7 '17 at 13:29
asked Dec 7 '17 at 9:52
Glebby
1116
1116
You can safely ignore the message. It will go away when issue #9076 is resolved.
– bricelam
Dec 8 '17 at 0:10
The problem is that the migration is not generating properly, it is empty.
– Glebby
Dec 8 '17 at 7:50
add a comment |
You can safely ignore the message. It will go away when issue #9076 is resolved.
– bricelam
Dec 8 '17 at 0:10
The problem is that the migration is not generating properly, it is empty.
– Glebby
Dec 8 '17 at 7:50
You can safely ignore the message. It will go away when issue #9076 is resolved.
– bricelam
Dec 8 '17 at 0:10
You can safely ignore the message. It will go away when issue #9076 is resolved.
– bricelam
Dec 8 '17 at 0:10
The problem is that the migration is not generating properly, it is empty.
– Glebby
Dec 8 '17 at 7:50
The problem is that the migration is not generating properly, it is empty.
– Glebby
Dec 8 '17 at 7:50
add a comment |
2 Answers
2
active
oldest
votes
up vote
2
down vote
Take a look at the OnModelCreating method in your DbContext. Make sure it calls base.OnModelCreating(builder)
. It should look something like:
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<T>().HasData(...);
}
If you are using builder.Entity<T>().HasData(...)
to seed your data, make sure you pass it a T and not an IEnumerable.
Very helpful: "If you are using builder.Entity<T>().HasData(...) to seed your data, make sure you pass it a T and not an IEnumerable"
– JuanK
Oct 15 at 7:41
add a comment |
up vote
1
down vote
My solution is to pass Array to HasData
function, not generic List
.
If you use List, try to convert array with ToArray
function.
add a comment |
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%2f47692179%2fparameter-count-mismatch-error-during-adding-entity-framework-migration-under%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
Take a look at the OnModelCreating method in your DbContext. Make sure it calls base.OnModelCreating(builder)
. It should look something like:
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<T>().HasData(...);
}
If you are using builder.Entity<T>().HasData(...)
to seed your data, make sure you pass it a T and not an IEnumerable.
Very helpful: "If you are using builder.Entity<T>().HasData(...) to seed your data, make sure you pass it a T and not an IEnumerable"
– JuanK
Oct 15 at 7:41
add a comment |
up vote
2
down vote
Take a look at the OnModelCreating method in your DbContext. Make sure it calls base.OnModelCreating(builder)
. It should look something like:
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<T>().HasData(...);
}
If you are using builder.Entity<T>().HasData(...)
to seed your data, make sure you pass it a T and not an IEnumerable.
Very helpful: "If you are using builder.Entity<T>().HasData(...) to seed your data, make sure you pass it a T and not an IEnumerable"
– JuanK
Oct 15 at 7:41
add a comment |
up vote
2
down vote
up vote
2
down vote
Take a look at the OnModelCreating method in your DbContext. Make sure it calls base.OnModelCreating(builder)
. It should look something like:
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<T>().HasData(...);
}
If you are using builder.Entity<T>().HasData(...)
to seed your data, make sure you pass it a T and not an IEnumerable.
Take a look at the OnModelCreating method in your DbContext. Make sure it calls base.OnModelCreating(builder)
. It should look something like:
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<T>().HasData(...);
}
If you are using builder.Entity<T>().HasData(...)
to seed your data, make sure you pass it a T and not an IEnumerable.
answered Sep 27 at 11:49
Connell.O'Donnell
1,3382525
1,3382525
Very helpful: "If you are using builder.Entity<T>().HasData(...) to seed your data, make sure you pass it a T and not an IEnumerable"
– JuanK
Oct 15 at 7:41
add a comment |
Very helpful: "If you are using builder.Entity<T>().HasData(...) to seed your data, make sure you pass it a T and not an IEnumerable"
– JuanK
Oct 15 at 7:41
Very helpful: "If you are using builder.Entity<T>().HasData(...) to seed your data, make sure you pass it a T and not an IEnumerable"
– JuanK
Oct 15 at 7:41
Very helpful: "If you are using builder.Entity<T>().HasData(...) to seed your data, make sure you pass it a T and not an IEnumerable"
– JuanK
Oct 15 at 7:41
add a comment |
up vote
1
down vote
My solution is to pass Array to HasData
function, not generic List
.
If you use List, try to convert array with ToArray
function.
add a comment |
up vote
1
down vote
My solution is to pass Array to HasData
function, not generic List
.
If you use List, try to convert array with ToArray
function.
add a comment |
up vote
1
down vote
up vote
1
down vote
My solution is to pass Array to HasData
function, not generic List
.
If you use List, try to convert array with ToArray
function.
My solution is to pass Array to HasData
function, not generic List
.
If you use List, try to convert array with ToArray
function.
answered Nov 20 at 6:06
ddagsan
1,0201212
1,0201212
add a comment |
add a comment |
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%2f47692179%2fparameter-count-mismatch-error-during-adding-entity-framework-migration-under%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 can safely ignore the message. It will go away when issue #9076 is resolved.
– bricelam
Dec 8 '17 at 0:10
The problem is that the migration is not generating properly, it is empty.
– Glebby
Dec 8 '17 at 7:50