WiX creating a table on an existing database - sql-server

I'm creating a plugin for an existing application and I need to add a table to the database this application is using (MSSQL-database). The problem is that I can't find any tutorial or documentation about how to do this with wix. I use msiext for the UI to retrieve the database server and the credentials to access and execute operations on the database.
I hope you can help me and if you need any additional information please ask me.

It is not in because it is a VERY bad idea to manipulate a database in the installer - which my and should normally not execute with permissions in the database.
You are a lot better off to follow best practices and handle database maintenance outside the application installation, as every other commercial application I have ever seen does. Generally DB updates and application updates are and should be separate.
If you HAVE To do it - execute a custom action.

Well eventhough it is not the most beautifull solution i managed to get it working with an sql script tag like:
<sql:SqlScript Id='CreateTable' BinaryKey='CreateTable' ExecuteOnInstall='yes' />
and it creates my table.

Related

Xamarin IOS/Android DOTMIM SYNC compatible with Azure Sql

I have an Xamarin cross platform application. I am currently storing my data in a Sqlite Database. However we want to have bi-directional syncing with an Azure Sql Database. After much reading I decided to give Dotmim Sync a try. The initial sync worked, however when adding a column to a table and attempting to migrate the data (following the tutorial), I got an error stating that the tracking table was missing. I redid everything again and realized that the entity tracking table was never created and I am not sure why. However Sql created a tracking table but it was not the entity tracking table that the error stated was missing.
I am curious if anyone with Xamarin has been able to successfully create bi-directional syncing with Sqlite and Azure Sql using Dotmim Sync. I have yet to find anything else that will work. Other than hand jamming it in this tutorial: https://www.xamarinhelp.com/mobile-database-bi-directional-synchronization-rest-api/
I am not against that, just seems like a lot of room for error. I am hoping someone out there has had success with what I am trying to do.
Hello I'm using Dotmim sync to synchronize a Sql Server database with a Sqlite database hotsted in a xamarin forms application through an API.
I think that I had the same problem as yours.
The problem is, as far as I understood, that the tracking tables are created only on the first sync.
If you change the schema of those tables you will need to call the Deprovision method.
This method will re-create the stored procedures and the triggers with the new database schema.
I'll leave you the link to the docs:
https://dotmimsync.readthedocs.io/Provision.html#provision-deprovision.

ASP.NET MVC 4 Membership Database

I have an ASP.NET MVC 4 app. My database is hosted on Windows Azure. My solution has a new SQL Server Database project. I want to start off by adding adding the ASP.NET Membership functionality to this Database [project]. My question is, how do I do that?
I thought it would be a straight forward drag and drop operation. However, I cannot figure out how to do this basic task. All of the online videos I find demonstrate how to to implement the login via the ASP.NET MVC side. However, I don't see anything that shows setting up the Membership tables/sprocs/views and getting them in a SQL Server Database project.
Thank you for any insights.
You can get the script(s) necessary for adding membership to a database using aspnet_regsql in your framework folder (usually %windows%\Microsoft.NET\Framework\v4.0.30319\). An example usage for producing the .sql file would be:
...\v4.0.30319>aspnet_regsql -sqlexportonly MembershipScript.sql
From there, run that script against your database. You may also need to play with the -d <database> flag, but all options can be shown using aspnet_regsql -?. (This includes exporting the necessary tables for session state and other options).
I hope that's what you were asking but if I've misunderstood the question please clarify and I'll do my best to revise the answer
The template for creating an MVC 4 Internet application with forms-based authentication uses both the traditional ASP.NET Membership database with an additional layer on top called SimpleMembership, which has its own database. The SimpleMembership database uses Entity Framework code-first model which creates the database automatically the first time you start the application. Since SimpleMembership uses code-first the database schema can be modified by changing the UserProfile class in AcccountModels.cs. What is your objective for putting these databases that are handled by the application into a separate database project? Unless you are going to bypass SimpleMembership any solution will have to handle two databases.

ASP.NET MVC Code-First EF - Possible to use EF without database create permissions?

So I'm working on an ASP.NET project for university. We have to upload our code to a server running IIS and SQL Server 2008. I've written my project using MVC Code-First EF. I understand that the Entity Framework system needs permission to create the database to work properly (you can't just give it an empty database and let it fill it with data). This has created a problem for me since I do not have database creation privileges on the shared SQL Server. Is there any way around this?
As you don't have permissions, it sounds like you'd need to get a DBA to create your database on the server you are trying to deploy to - this could be done from either a database creation script or from a database backup of the db on your dev machine. You can then instruct EF code first not to try to create / update the database automatically by adding this line to your global.asax (or indeed anywhere before you first access the database)
Database.SetInitializer<YourContextType>(null);
You can use an existing database, rather than let EF create one for you. I have done this myself, but admittedly only when using EF Migrations. Otherwise, you run into trouble with missing table exceptions and what not.
When using migrations, just point your connection string to your empty database, create an initial migration to populate the database with your schema and then update the database itself.
See this answer: How do I create a migration for an existing database in EntityFramework 4.3?
.. which include this nice link to getting started with EF Migrations: http://thedatafarm.com/blog/data-access/using-ef-migrations-with-an-existing-database/
All this is available through Nuget, and if you have access to Pluralsight content, I can highly recommend Julie Lerman's video on the topic.
If you don't want to use Migrations, you can still use Code First if you just create the database objects manually using SMMS, but obviously you have the manual work of keeping your model and the database in sync.

Copy sql server database using Entity Framework?

I'm having a problem with copying or scripting my database at a web host (which I need for use in a test application), and I'm not getting much help from their support. They don't seem to know what's wrong, but I can't do it because of some "access rights" problem.
So for the time being I'm trying to think of a temporary workaround. All I need is the schema, not the data. So I was thinking, maybe I could import the entire EF model into the test application and use the generate database from model command? But of course, that model is connected to the current database, and I want to generate the schema in a newly created database I have, leaving the current database intact.
Is it possible to do this? Can I just change the connection of the model to the new database, or won't this work, are there other dependencies or something? If it does work, how exactly do I do this? And if it doesn't, is there some other way to achieve this without relying on the web host to find the problem with copying in the near future...?
Please keep in mind that I'm no expert at databases, I just know the basics of the Entity Framework and Linq to Sql, so any specific SQL ideas I probably wouldn't understand (stored procedures and all that...)
You can copy your EF model and change the connection string. That should work fine.
You can export the schema of your database by: In server explorer => right click on the DB => Publish to provider and you follow the step. I will generate a SQL file that contains your schema and you import it on your server. Finally as Nik said you change the connection string.

Create database from edmx entity 3.5 file programmatically

I'm wanting to create a database programmatically from the edmx or edmx.sqlce file in my project. I read the best practice when sending the data out to users this is the best way. But I haven't found anything on it. Or is it best to create it and send it out with the program? How would I do updates to the database if I did this? How do I tell which version the database is?
Sorry for the multiple questions in one. I'm new to programming/databases so I don't know how it is normally done and can't seem to find a book on it either.
The best practice in this scenario is creating installation package (.msi) which will install your application and execute script to deploy the database. The script can even check dependencies like SQL Server CE and .NET Framework. This will also solve your problem with database version because .msi installation package keeps this information so you can create upgrade .msi which will know that it must execute only change script for database instead of creating a new one. Be aware that creating installation packages is pretty complex task but this is the way how it is done in real products shipped to customers. In both my current and previous company we used WiX to create installation packages but we have special guy who does this.
There is no API to create database from EDMX file. Moreover EDMX file is not part of built application. Database generation is feature of VS2010 which uses either workflow or T4 template to transform EDMX into SQL script. The default template can create only full database script and you must execute it.
I described the way of creating deployment script for new version of database in separate question. It is related to code-first (EFv4.1) but the principle is the same. If you need to keep information about database version you can have special table for that and check the value in the table at the beginning of the upgrade script.

Resources