c# - EF Core: Update-Database command not creating user tables -


following this tutorial created asp.net core 1.1.1 - code first app on vs2017 ver 15.3.3. difference between tutorial , app chose individual user accounts option , i'm using sql server 2012 express db instead of localdb. following commands run fine , create blogging database blogs , posts tables. note: i've not upgraded .net core 2.0 yet on both computers compatibility issues of our existing applications.

pm> add-migration myfirstmigration -context bloggingcontext pm> update-database -context bloggingcontext 

issue

but when run following command generate user tables (aspnetusers, aspnetrols etc) command runs without error user tables not created. not happening before upgraded vs2017 ver 15.3.3. also, on other computer (windows 10 sqlexpress 2014) don't have such problem. computer windows 7. possibly issue here - , may missing here?

update-database -context bloggingcontext 

.csproj file

<project sdk="microsoft.net.sdk.web">    <propertygroup>     <targetframework>netcoreapp1.1</targetframework>     <packagetargetfallback>$(packagetargetfallback);portable-net45+win8+wp8+wpa81;</packagetargetfallback>     <usersecretsid>aspnet-forgotpassword-b181aa40-ba34-4a36-a650-38857d8e8177</usersecretsid>   </propertygroup>     <itemgroup>     <packagereference include="microsoft.applicationinsights.aspnetcore" version="2.0.0" />     <packagereference include="microsoft.aspnetcore" version="1.1.2" />     <packagereference include="microsoft.aspnetcore.authentication.cookies" version="1.1.2" />     <packagereference include="microsoft.aspnetcore.diagnostics.entityframeworkcore" version="1.1.2" />     <packagereference include="microsoft.aspnetcore.identity.entityframeworkcore" version="1.1.2" />     <packagereference include="microsoft.aspnetcore.mvc" version="1.1.3" />     <packagereference include="microsoft.aspnetcore.staticfiles" version="1.1.2" />     <packagereference include="microsoft.entityframeworkcore.design" version="1.1.2" privateassets="all" />     <packagereference include="microsoft.entityframeworkcore.sqlserver" version="1.1.2" />     <packagereference include="microsoft.entityframeworkcore.sqlserver.design" version="1.1.2" privateassets="all" />     <packagereference include="microsoft.entityframeworkcore.tools" version="1.1.1" privateassets="all" />     <packagereference include="microsoft.extensions.configuration.usersecrets" version="1.1.2" />     <packagereference include="microsoft.extensions.logging.debug" version="1.1.2" />     <packagereference include="microsoft.visualstudio.web.codegeneration.design" version="1.1.1" privateassets="all" />     <packagereference include="microsoft.visualstudio.web.browserlink" version="1.1.2" />   </itemgroup>    <itemgroup>     <dotnetclitoolreference include="microsoft.entityframeworkcore.tools.dotnet" version="1.0.1" />     <dotnetclitoolreference include="microsoft.extensions.secretmanager.tools" version="1.0.1" />     <dotnetclitoolreference include="microsoft.visualstudio.web.codegeneration.tools" version="1.0.1" />   </itemgroup>  </project> 

applicationdbcontextmodelshapshot.cs

[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("forgotpassword.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("forgotpassword.models.applicationuser")                     .withmany("claims")                     .hasforeignkey("userid")                     .ondelete(deletebehavior.cascade);             });          modelbuilder.entity("microsoft.aspnetcore.identity.entityframeworkcore.identityuserlogin<string>", b =>             {                 b.hasone("forgotpassword.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("forgotpassword.models.applicationuser")                     .withmany("roles")                     .hasforeignkey("userid")                     .ondelete(deletebehavior.cascade);             });     } } 

update

i tried above test selecting asp.net core 2.0 template on computer has .net core 2.0 , vs2017 ver 15.3.3 , worked fine expected - same sql server version sqlexpress2012. blogging db created blogs , posts tables , user tables aspnetusers, aspnetroles etc. problem seems when have .net core 1.1.1 on system vs2017 ver 15.3.3 , trying create asp.net core 1.1.1 web app individual user accounts applicationdbcontext not work.

when running commands add migrations , update database referencing bloggingcontext , showing snapshot of applicationdbcontext. applicationdbcontext comes individual user accounts template have chosen, if want identity tables (user table 1 of them) should extend applicationdbcontext instead of creating new one.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -