c# - EF-Core: Update-Database command error: Keyword not supported -
on vs2017 ver 15.3.3,
created asp.net core 1.1.1
app individual user account
mode. i'm using this tutorial official asp.net team. following package-manager (pm) commands works fine , creates blogging database:
pm> add-mogration myfirstmigration -context bloggingcontext pm> update-database -context bloggingcontext
but when run following command on same database, following error:
pm> update-database -context applicationdbcontext
error:
keyword not supported: 'int2450134508l\sqlexpress2012;database'.
note:
- as know
applicationdbcontext
class asp.net core automatically creates under myproject\data folder along migration files under myproject\data\migrations folder when chooseindividual user account
mode - database
connection string
same follows (instartup.cs
,appsettings.json
) , works fine bloggingcontext:
connection string:
var connection = @"server=int2450134508l\sqlexpress2012;database=forgotpswd;trusted_connection=true";
update
the application copied windows 10
windows 7
. database on windows 10 on sql server 2014 express , on windows 7 it's sql server 2012 express
. on windows 10 both update-database command worked fine both bloggingcontext , applicationdbcontext - blogging database created both blogging , aspnet identity tables (aspnetusers, aspnetroles etc). since cannot restore db later version previous one, not use same db backup frm sql2014. on win7, deleted migration scripts bloggingcontext, , ran add-migration command again on bloggincontext re-create migrations scripts bloggingcontext. did not touch touch migration scripts applicationdbcontext. update-database command on bloggingcontext ran fine , and created blogging db on win7. when ran same command on applicationdbcontext got error shown above.
following applicationdbcontextmodelsnapshot.cs
file created vs2017
on win10
, did not change on win7
:
namespace mvc_indvuseraccts_test.data.migrations { [dbcontext(typeof(applicationdbcontext))] partial class applicationdbcontextmodelsnapshot : modelsnapshot { protected override void buildmodel(modelbuilder modelbuilder) { modelbuilder .hasannotation("productversion", "1.0.0-rc3") .hasannotation("sqlserver:valuegenerationstrategy", sqlservervaluegenerationstrategy.identitycolumn); modelbuilder.entity("microsoft.aspnetcore.identity.entityframeworkcore.identityrole", b => { b.property<string>("id"); b.property<string>("concurrencystamp") .isconcurrencytoken(); b.property<string>("name") .hasannotation("maxlength", 256); b.property<string>("normalizedname") .hasannotation("maxlength", 256); b.haskey("id"); b.hasindex("normalizedname") .hasname("rolenameindex"); b.totable("aspnetroles"); }); modelbuilder.entity("microsoft.aspnetcore.identity.entityframeworkcore.identityroleclaim<string>", b => { b.property<int>("id") .valuegeneratedonadd(); b.property<string>("claimtype"); b.property<string>("claimvalue"); b.property<string>("roleid") .isrequired(); b.haskey("id"); b.hasindex("roleid"); b.totable("aspnetroleclaims"); }); modelbuilder.entity("microsoft.aspnetcore.identity.entityframeworkcore.identityuserclaim<string>", b => { b.property<int>("id") .valuegeneratedonadd(); b.property<string>("claimtype"); b.property<string>("claimvalue"); b.property<string>("userid") .isrequired(); b.haskey("id"); b.hasindex("userid"); b.totable("aspnetuserclaims"); }); modelbuilder.entity("microsoft.aspnetcore.identity.entityframeworkcore.identityuserlogin<string>", b => { b.property<string>("loginprovider"); b.property<string>("providerkey"); b.property<string>("providerdisplayname"); b.property<string>("userid") .isrequired(); b.haskey("loginprovider", "providerkey"); b.hasindex("userid"); b.totable("aspnetuserlogins"); }); modelbuilder.entity("microsoft.aspnetcore.identity.entityframeworkcore.identityuserrole<string>", b => { b.property<string>("userid"); b.property<string>("roleid"); b.haskey("userid", "roleid"); b.hasindex("roleid"); b.hasindex("userid"); b.totable("aspnetuserroles"); }); modelbuilder.entity("microsoft.aspnetcore.identity.entityframeworkcore.identityusertoken<string>", b => { b.property<string>("userid"); b.property<string>("loginprovider"); b.property<string>("name"); b.property<string>("value"); b.haskey("userid", "loginprovider", "name"); b.totable("aspnetusertokens"); }); modelbuilder.entity("mvc_indvuseraccts_test.models.applicationuser", b => { b.property<string>("id"); b.property<int>("accessfailedcount"); b.property<string>("concurrencystamp") .isconcurrencytoken(); b.property<string>("email") .hasannotation("maxlength", 256); b.property<bool>("emailconfirmed"); b.property<bool>("lockoutenabled"); b.property<datetimeoffset?>("lockoutend"); b.property<string>("normalizedemail") .hasannotation("maxlength", 256); b.property<string>("normalizedusername") .hasannotation("maxlength", 256); b.property<string>("passwordhash"); b.property<string>("phonenumber"); b.property<bool>("phonenumberconfirmed"); b.property<string>("securitystamp"); b.property<bool>("twofactorenabled"); b.property<string>("username") .hasannotation("maxlength", 256); b.haskey("id"); b.hasindex("normalizedemail") .hasname("emailindex"); b.hasindex("normalizedusername") .isunique() .hasname("usernameindex"); b.totable("aspnetusers"); }); modelbuilder.entity("microsoft.aspnetcore.identity.entityframeworkcore.identityroleclaim<string>", b => { b.hasone("microsoft.aspnetcore.identity.entityframeworkcore.identityrole") .withmany("claims") .hasforeignkey("roleid") .ondelete(deletebehavior.cascade); }); modelbuilder.entity("microsoft.aspnetcore.identity.entityframeworkcore.identityuserclaim<string>", b => { b.hasone("mvc_indvuseraccts_test.models.applicationuser") .withmany("claims") .hasforeignkey("userid") .ondelete(deletebehavior.cascade); }); modelbuilder.entity("microsoft.aspnetcore.identity.entityframeworkcore.identityuserlogin<string>", b => { b.hasone("mvc_indvuseraccts_test.models.applicationuser") .withmany("logins") .hasforeignkey("userid") .ondelete(deletebehavior.cascade); }); modelbuilder.entity("microsoft.aspnetcore.identity.entityframeworkcore.identityuserrole<string>", b => { b.hasone("microsoft.aspnetcore.identity.entityframeworkcore.identityrole") .withmany("users") .hasforeignkey("roleid") .ondelete(deletebehavior.cascade); b.hasone("mvc_indvuseraccts_test.models.applicationuser") .withmany("roles") .hasforeignkey("userid") .ondelete(deletebehavior.cascade); }); } } }
Comments
Post a Comment