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
by using command install entity framework successfully.
pm> enable-migrations
by using command created migration file in project.
pm> update-database
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
Post a Comment