I delete my database in SQL Server and my data model layer in WPF project and then create new database and layer. In project show me last table in last database. How can delete this data?
I change connection string after add new layer and when delete database I delete every connection string
when I create first table in first database I use name "user" for table name instant "users"
Related
I need multi database concept for my project. I create user on real time automatically create new database for that new user .that new user login switched to master database to user database.. how to do this .. I am trying larval 5.4 version .
1.How to create database on real-time for new user ?
2.How to switch users login master database to user database ?
You can create schemas and migrate them real time, I've done exactly this before in a project. Use the following
DB::connection('mydb')->statement(DB::raw('CREATE DATABASE....BLAH BLAH BLAH'))
to execute raw queries for creating new databases. You'll need your master connection to execute these queries.
Then you can use Artisan::call('migrate', ['--database' => 'newdb']) to migrate and optionally seed it.
Finally, you will need to either have a customers entry in your database config file that determines which schema the user connects to, or you can set this real time using Config::set(['my.user.db.config').
My strategy for creating unique databases for the customer was to use a guid as the database name and keep a master log of that in my master database. When a user would log in, their database name would be read from master and then the application would switch his connection on the fly. My company has hundreds of small customer databases with names like 123151-2135151-5132123-545-231231 that keep them unique.
It's quite involved and there are a lot of moving pieces but that will get you started.
I have deleted and modified somes tables in database sqlserver manually, then I have deleted __MigrationHistory table...
Now, when i run "add-migration" command, it regenare commands for recreate entire structure of database, but I want to syncronize the structure from the model to database, without recreates all tables in database...
the comnand "add-migration -ignoreChanges" is not correct, because the
model of website is different from database, because i have manual
modified somes tables.....
is possibles?
thanks
I need our end-users to "clone" a database from our web application UI. I am able to "clone" a database by backing up a source database and restoring it into a new database. In this way, I "clone" the table schema and data.
My question is - is there any way I can "clone" just the table schema, without the data? I am aware that we can script the database manually, and run that script. But our table schema changes frequently (we add new columns and tables regularly) and we wouldn't want to update this script. Thank you.
basically you have to:
save the datatase
restore the backup to a new database (use the with move option)
connect to the new database and then exec sys.sp_MSforeachtable 'truncate table ?'
PS: you may have to disable FK constraints if any.
Antother solution: use Entity Framework Database First to build a small program. Launch said program with a connection string pointing to a new db.
Right Click over database -> Tasks -> Generate Script
On Set Scripting Options page click Advanced
General -> Types of data to script = Schema Only
With SQL Server data tools you can generate the schema difference and apply only the changes to target database.
When I create any new database It automatically create some tables in new database.
Details:
I created a new database "TestDatabase" using below command
Create database TestDatabase
When I expand the Tables folder, I found that there are already some tables created automatically.
These are those tables which I was using in some other database.
Table names:
1. Employee
2. Admin
etc
How can I create new fresh database to make sure that no tables created in it?
Presumably at some point you accidentally created these tables in the model database.
This is used as the template for creating new databases. Simply delete them from model to stop them appearing in every freshly created database.
SQL Server uses the model database as the basis for new databases. Check and see if these tables exist in model - and if they do, delete them.
You should probably check for other objects in modeltoo (stored procedures, views etc).
I have Visual Studio 2008:
I can create Entity Framework models on existing tables in a SQL Server 2005 database.
I can create Entity Framework models on tables I create in a local SQL Server 2008 database files.
However, when I add a new table to the SQL Server 2005 database, then try to create an Entity Framework model on it, it lets me click the little checkbox next to the table and finish, but the .edmx/...Designer.cs file consists only of four methods but nothing about the table that I selected, as if the I hadn't selected it.
What could be causing code not to be generated on the table I selected?
Where could I look for error messages regarding the attempted creation of code for this table?
0) I think, you have added and then deleted this table before. In this case you should open model file (Designer.cs), remove all this table related records (manualy) and then refresh the model.
1) Maybe you have many-to-many relationship tables. EF decides no to add "link" table in this case.
2) Maybe you have a table that has two fields (PK and FK to other one) ONLY. In this case EF does the same.
3) Install later SP to VS and framework.
4) Check connection string.