c# - update the database from package manager console in code first environment -


code first environment

i'm trying update database package manager console.if domain class change, have drop , create database,instead of dropping database how can update database.

i have try reading blogs in google.

commands

pm> install-package entityframework 
  1. by using command install entity framework successfully.

     pm> enable-migrations 
  2. by using command created migration file in project.

     pm> update-database 
  3. by using command , may update table have problem here.

error

specify '-verbose' flag view sql statements being applied target database. system.data.sqlclient.sqlexception (0x80131904): network-related or instance-specific error occurred while establishing connection sql server. server not found or not accessible. verify instance name correct , sql server configured allow remote connections.

doubt here

sometimes may update if 1 field changes in poco class. example have updated more number of domain class ,how can update database package manager console. idea ?

you can specify connection string via connectionstring parameter:

update-database -connectionstring "data source=server_name;initial catalog=db_name;integrated security=true;multipleactiveresultsets=true;app=entityframework" -connectionprovidername "system.data.sqlclient" -verbose 

also need use parameter same value add-migration command:

add-migration version_name -connectionstring "data source=server_name;initial catalog=db_name;integrated security=true;multipleactiveresultsets=true;app=entityframework" -connectionprovidername "system.data.sqlclient" -verbose 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -