Suppose I have two MS LightSwitch projects. I really like my table layout in one project and want to copy it to the other project. How is this done? What files have the table and key definitions?
The easiest way would be to publish the application, then use a copy of the published database as an attached data source in the new project.
The defintions that you ask about are stored in an lsml file (a LightSwitch-specific XML file), ApplicationDefinition.lsml for LS 2011, & Common.lsml for LS 2012. But be VERY careful if you try to edit this file in any project, it only takes ONE mistake for the whole application to no longer load.
[WARNING: NEVER DO THE FOLLOWING! IT MESSES UP YOUR PROJECT IN VISUAL STUDIO]
What I did in LS 2013 was to create tables with the same name in the new project, so they are already "known" to your project settings. Then I went to [project folder]\[project name]\[project name]\[project name].server\DataSources\ApplicationData of the project I wanted the tables from. I copied the respective files (including script files, if you did data validation, which I also created in the new project with dummy entries) and then overwrote the files with the same name in the respective ApplicationData folder of the new project, which I had created.
When I loaded the project again, Lightswitch showed the new tables in my old project.
Related
I have two different projects sharing same SQLite database(One is Web-api, Other one is WPF App). However, the database is located in (let's say project A). In the project B, I used "Add as link" to copy the DB to project B.
I have three questions
If the DB in project A changes, the linked DB also changes. However, if i change the DB in project B, does the original DB change?
Is there any better way to do this?
Will it still work if i release the solution.
original DB
copied DB
properties of copied DB
A local database like a sqllite file should be installed to appdata.
This is user specific by default, but there's also a public user you could use.
It's up to your installer - and that means you - to put it there.
If this file is to be shared by two apps.
You would need to configure whatever you're using as an installer to write to a common location in appdata. That should be under public if multiple users need to share the file.
By default, if you add a file as content and copy if newer that will end up in your bin when you develop and it will work for you. When you install, if you install to program files the sdf will end up in there as well and your user will not be able to write to it.
There's a more complete explanation of appdata files here:
https://social.technet.microsoft.com/wiki/contents/articles/30915.c-local-files.aspx
Hi All I have a VS 2008 ASP.NET solution with website project and many other projects. I've had to add new items to the Web Stite part of the solution. I added them (new items) in Visual Studio that part is OK. Now I need to check in my changes to Version Control. I added new files. But I think I also need to check in a .csproj file which has info about the new item I added. And here lays the problem. I found the sln file which lists all the .csproj files, but I added the new items to the Web Site project and there isn't a .csproj file for it anywhere? The .sln file does no list the items which are part of this project so where is this info in? What file do I need to check in for the project to know about those new items I added to it. I've been pulling my hair for a couple of hours. Please help
I'm developing a Windows Form application with Visual Studio 2013 that needs access to multiple Oracle databases.
The main application is an MDI window and from a menu you can open many different child forms. Each child form has access to a different Oracle database and shows different DataGridView and other data controls.
I'm using Oracle Developer Tools and the child forms contains Oracle controls taken from the VS Toolbox, using drag and drop and wizard, so DataBinding is automatically configured.
The solution consists of 3 projects: Main Application EXE (contains forms, DataSet.xsd and .config files), Data Access Classes DLL, Reports DLL (contains RDLC reports as embedded files).
For each database I need to refer to the same ConnectionString, both for design time (used by wizards) and runtime. At design time, the form controls automatically use a reference to the DataSet.xsd file and so the ConnectionString automatically created the first time with the wizard. Then I also need to access to the same database during runtime and so when I deploy the application I need to keep all the correct references, both for debug and release.
Now I have all the ConnectionStrings and DataSets XSD files stored on the Main App EXE project and my actual config files are:
When I add a new report on the Reports DLL project using the Report Wizard Tool, I'm asked to create a new DataSet and so a new ConnectionString because Visual Studio doesn't show me the existing connections stored inside the Main App EXE project.
To sum up I need to be able to:
Share ConnectionStrings between Main App EXE project and Reports DLL project;
Share DataSets XSD files between Main App EXE project and Reports DLL project;
Have distinct ConnectionStrings for Debug/Release and share them all between projects;
Automatically update DataSets XSD files whenever I make changes to the underlying databases;
Change database context (test environment for debug and production environment for release) without breaking DataSet.xsd or, if this is not possible, by having two distinct DataSet XSD files, one for test and another one for production, that are automatically selected based on the debug/release mode.
Now I need to manually change code in XSD file to replace the ConnectionString (test/production). But since the DataSet refers to the same database structure I need a mechanism to make this easier.
Lately i was building C# windows forms application with service-based database.
I was forced to make few changes to make it work, but it's still not working as it should.
I'am doing this at start:
1. Add Service-based database to project
2. Create Tables
3. Add Entity framework 6.1.2 Model to project
This creates seccond database file in Project and in Data Connection. Now if i want to show any data, I must create dgv and dataSet pointing at this newly created .mdf file. Also i need to change Copy to Output Directory to Copy if newer. Now I can see my data, but i only see empty table in Data Connection in Server Explorer. Also if I open it and refresh, all data in my application are gone.
Is there any tutorial, or something about How to add Service-based database and connect to this file using entity framework, wihout coppying it to output directory?
If someone need a solution for this case, there is one:
Create database in any program (could be visual studio)
Copy it to /bin/debug/
Put bin folder to your solution in Visual Studio
Select database and make Copy to Output - Do not copy
Edit connection string in entity framework to
attachdbfilename=|DataDirectory|\file.mdf;
Database should now appear in Server Explorer in VS. You can now remove all newly created databases (leave only this one you copy to bin/debug/)
Now you will see correct database in Data Connections, and your program will update this one. You can easily coppy your solution to any other location, and connections will not be messed up.
Btw, I think this is entity framework error or DataDirectory should point to Solution folder, not bin/debug. I know we can change DataDirectory pointing...
I am creating a C# winform application that is using a .mdf database I am creating and attaching to the project via the Add New -> Service Based Database. I can add the database and and add tables just fine via Visual Studio and programatically. But when I go to view the data in Visual Studio, my data I inserted is not present. I believe this is because of the fact that the .mdf file that Visual Studio sees and reads is in the project folder where as the .mdf file the code modifies is put in the bin folder.
Please refer the MSDN link : How to: Manage Local Data Files in Your Project