0

I'm having trouble to recreate my C# project on a virtual machine.

Basically, I've copied my project, opened it on my virtual machine. Scaffolded so I get the SQL database to talk to my project on the virtual machine after I manually created some tables in SQL.

PROBLEM: How do I get the Identity framework sql data-Tables into my virtual machien SQL tables section? I would like the tables highlited in yellow on the left (my original machine sql) to also be present on my virtual machine sql, the right side of the picture.

How can I get this automatically? Nuget for identity framework is downloaded but I guess there is some sort of scaffolding or similar?

Picture of what I mean

JoBo
  • 235
  • 4
  • 17

1 Answers1

0

If I understand you correctly you want to create tables for Identity. You have 2 options here:

  1. Use Migrations like described in this post

  2. Or just generate SQL scripts for Identity tables using EF Core or SQL Management Studio, since you have SQL Management Studio according to you screen you can use it to generate Script for particular tables using Task->Generate Scripts... while right click on your Database.

enter image description here

And then just choose the tables you need and then choose Save to new query window. enter image description here

  1. If database not very huge, you can also use Task->Back up... save it on your machine. Then copy this backup to virtual machine and restore it there using Restore Database. You can even just use SQL for this like described here.
user2771704
  • 5,994
  • 6
  • 37
  • 38
  • Nice! I went with option 2. Really good help, with pictures and eveything. This seemed to have done the trick. One last questions before I mark your answer as perfect and complete. I did the query on my old sql, copied the query and ran it on my database in my new sql on my virtual machine. 3 warnings which I don't understand (tried googling them ), PLEASE SEE BELOW, does this matter as the identity framework tables where basically empty, was only three lines in there for roles and the amounts of char in every column was never more than 20: – JoBo Aug 22 '17 at 09:43
  • Warning! The maximum key length is 900 bytes. The index 'PK_AspNetUserLogins' has maximum length of 1800 bytes. For some combination of large values, the insert/update operation will fail. Warning! The maximum key length is 900 bytes. The index 'PK_AspNetUserRoles' has maximum length of 1800 bytes. For some combination of large values, the insert/update operation will fail. Warning! The maximum key length is 900 bytes. The index 'PK_AspNetUserTokens' has maximum length of 2700 bytes. For some combination of large values, the insert/update operation will fail. – JoBo Aug 22 '17 at 09:43
  • Also it says "Invalid Object Name" and "Invalid Column Name" When I choose top 1000 from one of the newly created tables: SELECT TOP (1000) [UserId] ,[Username] ,[Password] ,[Email] ,[CreatedDate] ,[LastLoginDate] ,[FullAccess] FROM [MVCRepetition].[dbo].[LoginData] – JoBo Aug 22 '17 at 09:46
  • @Johan 1) About 900 bytes, doesn't seem to be a problem since 900 bytes is 450-1=449 characters, I don't think you will use such huge IDs. – user2771704 Aug 22 '17 at 11:31
  • @Johan 2) Strange, try to clear the cache like here https://stackoverflow.com/questions/1362531/sql-server-invalid-object-name-but-tables-are-listed-in-ssms-tables-list – user2771704 Aug 22 '17 at 11:39