Entity Framework 7 RC1 Reverse Engineer Entire DB only? - entity-framework-core

I have successfully reverse engineered my DB in EF7 RC1, specifically using the Package Manager Console command 'Scaffold-DbContext', as described in their documentation.
First, are there any options for reverse engineering just some of the tables in the DB? Most of my projects use only a few of the hundreds of tables in the DB.
Secondly, if we change the DB and want to reverse engineer it a second time what is the correct procedure? If I simply re-run the command it says 'Build failed' presumably because the models already exist.

are there any options for reverse engineering just some of the tables in the DB?
Yes. To see options, execute get-help Scaffold-DbContext in the Package Manager Console. This is the output for 7.0.0-rc1-final. To limit selection to only some tables, use the -Tables options
PM> get-help Scaffold-DbContext
NAME
Scaffold-DbContext
SYNOPSIS
Scaffolds a DbContext and entity type classes for a specified database.
SYNTAX
Scaffold-DbContext [-Connection] <String> [-Provider] <String> [-OutputDirectory <String>] [-ContextClassName <String>] [-Schemas <String[]>] [-Tables <String[]>] [-DataAnnotations]
[-Project <String>] [-StartupProject <String>] [-Environment <String>] [<CommonParameters>]
DESCRIPTION
Scaffolds a DbContext and entity type classes for a specified database.
RELATED LINKS
about_EntityFramework
REMARKS
To see the examples, type: "get-help Scaffold-DbContext -examples".
For more information, type: "get-help Scaffold-DbContext -detailed".
For technical information, type: "get-help Scaffold-DbContext -full".
For online help, type: "get-help Scaffold-DbContext -online"
if we change the DB and want to reverse engineer it a second time what is the correct procedure?
Delete your old model classes and context and re-run reverse engineering from the updated database. Scaffold-DbContext does not make in-place updates in RC1.

This is a a known issue with the EF7 version which will be released. Rowan Miller told this here.
You have to wait for the next large EF7 Update which will bring back some features that are missing.

Related

Is property or field 'ServerRelativeUrl' part of the command Get-PnPFolderItem

I am getting the following error while using the command "Get-PnPFolderItem"
Get-PnPFolderItem : The property or field 'ServerRelativeUrl' has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
I checked the documentation and there is no reference of it
Get-PnPFolderItem
[-FolderSiteRelativeUrl <String>]
[-ItemType <String>]
[-ItemName <String>]
[-Web <WebPipeBind>]
[-Connection <SPOnlineConnection>]
Per my test, the command "Get-PnPFolderItem" works fine on my environment. So, yes it should be part of the command Get-PnPFolderItem.
Please maek sure the version of your SharePointPnPPowerShellOnline is the lastest. Also try to connect another site and check if it works.

Entity Framework 6 and applying migration to remote database

I'm new to EF 6 and struggling how to easily apply migrations to the "remote" database. My local database is SQL Server Express and my remote database is SQL Server at GoDaddy. When I apply migrations and update the database, it appears to use the connection string from my web.config. The way I was able to apply the migration to my remote database was to swap the connection strings from my Web.Release.config and web.config files and then perform an Update-Database -TargetMigration {name of the migration}.
Are there any commands that I can use to target a specific database (without swapping the connection strings)? I've used get-help update-database but can't seem to find what I'm looking for.
Thank you
You need to apply command line switch.
Update-Database [-SourceMigration <String>] [-TargetMigration <String>] [-Script] [-Force]
[-ProjectName <String>] [-StartUpProjectName <String>] [-ConfigurationTypeName <String>]
-ConnectionString <String> -ConnectionProviderName <String>
[-AppDomainBaseDirectory <String>] [<CommonParameters>]
EF Migrations Command Reference

Why is New-SelfSignedCertificate is missing parameter -Type?

I try to sign my ps.1 file and wanted to create a code signing certificate but my New-SelfSigningCertificate does not have the parameter -Type in the function.
I use PowerShell 5.1.
When I use Get-Help, the description oddly enough also displays much less parameters than on the microsoft website. Opening the online help via Get-Help does not work because the URI is not specified.
The Help content:
SYNTAX
New-SelfSignedCertificate [-DnsName <string[]>] [-CloneCert <Certificate>]
[-CertStoreLocation <string>] [-WhatIf] [-Confirm] [<CommonParameters>]
Am I using an outdated version? Is this command only properly available in Win 10 or Server 2016?

SQL Azure powershell commands not recognized anymore. Deprecated?

Already discussed at: Get-AzureSqlDatabaseServer : The term 'Get-AzureSqlDatabaseServer' is not recognized as the name of a cmdlet
I just need to be sure if this behavior is due to the whole Azure Services Management deprecated ? Replaced by AzureRM or is it something else ?
If the cmdlet doesn't start with <verb>-AzureRm* then it's not part of the AzureRm module.
Get-AzureSqlDatabaseServer appears to be part of the Azure module, which is deprecated.
Perhaps you are looking for Get-AzureRmSqlServer?
Get-Help Get-AzureRmSqlServer
NAME
Get-AzureRmSqlServer
SYNOPSIS
Returns information about SQL Database servers.
SYNTAX
Get-AzureRmSqlServer [[-ResourceGroupName] <System.String>] [[-ServerName]
<System.String>] [-DefaultProfile <Microsoft.Azure.Commands.Common.Authenticatio
n.Abstractions.IAzureContextContainer>] [-Confirm
<System.Management.Automation.SwitchParameter>] [-WhatIf
<System.Management.Automation.SwitchParameter>] [<CommonParameters>]
DESCRIPTION
The Get-AzureRmSqlServer cmdlet returns information about one or more Azure SQL
Database servers. Specify the name of a server to see information for only that
server.

How to restart/merge migration?

I'm using Entity framework code first and I have almost 10 migrations now. I found a design issue and some of the DBMigrations are not what I expected and I want to re-generated the database.
How to discard all these existed migrations and regenerate the tables on development database? (delete all the cs files under Migrations folder and delete the database? What if I want to keep the first xxxxxx_InitialCreate.cs and restart from there?)
What if the database already published to production database server? What's the best way to sync the development database/migrations and production database/migrations?
You could revert to that initial migration
Update-Database [-SourceMigration <String>] [-TargetMigration <String>]
[-Script] [-Force] [-ProjectName <String>] [-StartUpProjectName <String>]
[-ConfigurationTypeName <String>] -ConnectionString <String>
-ConnectionProviderName <String> [<CommonParameters>]
is the Syntax so:
Update-Database -TargetMigration InitialCreate
reverts your database to the initial migrationFor the second part I would just change the connection string to the production database and run the migration again. No loss of data should occur.