Updating Schema Of Production Database With NHibernate And Adding Default Data?
Sep 24, 2010
here's the situation:
You're using NHibernate with Fluent NHibernate for mappings.
You have an application in production with a database with live data You're adding a new feature in development and it requires a new database column.
The new column cannot be blank. For example, I recently had to a DateCreated column to a table and the app now uses that date. As the only time the data will be missing is now, it seems unnecessary to add code to check for errors.
In my application I have an updater which can execute a SchemaUpdate to add the new database column - however, the application will starting crashing as it is expecting a value in the new column.
I need to get some sensible default data into that column. In this case I manually ran an Update to set the date to the current date (good enough for the situation). In this particular case I believe that you cannot set the column default to getdate() using fluent mappings.
Keep a schema version number in a config file In the updater that runs SchemaUpdate start adding upgrade methods for each version. These methods would run updates to add default data (or other required actions).
After the schema update has been run, call all methods required for a version greater than the current version (i.e. those that haven't previously been run). So if the app is now version 4 and version 2 is installed, methods 3 and 4 would be run.
View 3 Replies
Similar Messages:
Aug 7, 2010
I'm currently creating a small web app that requires users to log in before accessing any features.
I'm using Visual Web Developer 2010 and I have created a database in the App_Data folder of my project that I now wish to add the required tables, views and stored procedures to in order to use the SqlMembershipProvider. I have ran the aspnet_regsql file and entered the required details and completed all the required steps; however, when I return to Visual Web Developer and refresh the database I created, nothing happens, there are no tables or stored procedures.
Although nothing has been added to the database in my project, when I open up SQL Server Management Studio, my database appears with all the relevant tables, views etc.
Is there any reason why the database with all the required tables etc appears in SQL Server Management Studio but not in my project in Visual Web Developer?
I'm getting rather confused as I have completed this before on another project on a different machine and it worked fine.
View 2 Replies
Jan 29, 2010
am trying to implement fluent nhibernate in MVC project...there were no build errors... but when i run the project i get this exception
System.Xml.Schema.XmlSchemaValidationException: The element 'class' in namespace 'urn:nhibernate-mapping-2.2' has incomplete content. List of possible elements expected: 'meta, subselect, cache, synchronize, comment, tuplizer, id, composite-id' in namespace 'urn:nhibernate-mapping-2.2'.
have no idea what am doing wrong here... the following is the code for opening session factory...
[code]....
View 3 Replies
Jul 20, 2010
I have a SQL Server 2008 DB with many tables filled with data and I used SQL Server Management Studio to generate a SQL dump by using the Script Wizard : Tasks -> Generate Scripts -> Script All objects in the selected database and also selecting the option to Script Data. I made sure to change the value of "Script for Server Version" to "SQL Server 2008". Then I created a new DB and ran the SQL dump on the new DB to generate an identical copy of the old DB. Then I assigned permissions to my default user to the new DB. Then I changed the connection string on my ASP.NET application to use the new DB. But when I run it, it throws the following exception -
Server Error in '/myapp' Application. The 'System.Web.Security.SqlMembershipProvider' requires a database schema compatible with schema version '1'. However, the current database schema is not compatible with this version. You may need to either install a compatible schema with aspnet_regsql.exe (available in the framework installation directory), or upgrade the provider to a newer version. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Configuration.Provider.ProviderException: The 'System.Web.Security.SqlMembershipProvider' requires a database schema compatible with schema version '1'. However, the current database schema is not compatible with this version. You may need to either install a compatible schema with aspnet_regsql.exe (available in the framework installation directory), or upgrade the provider to a newer version.
Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:.........................
View 2 Replies
Jan 31, 2011
I have two table BuildGroup and table DocumentTemplate. DocumentTemplate table has BuildGroupId as foreign key which is nullable. In a certain senario I update BuildGroupId in DocumentTemplate table.
[Code].....
In another senario I need to set BuildGroupId in DocumentTemplate table again to dbnull.value. I tried with different cases as in else block. It giving the error : Cannot implicitly convert type 'System.DBNull' to 'int'. How can I update a foreign key value with NULL?
View 2 Replies
Feb 3, 2011
I have an xsd that describes XHTML documents. However the application I'm working with may have some selected asp.net controls within to the markup at the point is validated. Therefore the validation fails.
An example control could be:
<smart:Address runat="server" />
I wanted to add a new element to the xsd file but when I specify:
<xs:element name="smart:Address">
I get validation errors as an element name must not have a colon in it.
how I might be able to extend the schema file to allow selected server controls?
View 2 Replies
Jul 6, 2010
Sometimes I would like to be able to update during day time my ASP .Net application. I noticed that quite often updating DAL's (.xsd files) that are in used will block my application (and users). The only way, I found to recover, is to restart IIS but my users do not like it.
Is there some more clean way to update an online server without disrupting the users ?
Could I identified the DAL which are in used and the users using them, so that I could somehow disconnect only these users (My application uses Windows authentication).
View 1 Replies
Jun 29, 2010
I'm working on a new project where I have the luxury of working from a Model to Database approach using Entity Framework 4.
The project I'm working on is taking an agile approach where different phases will be rolled out over time.
Will the Model First approach work in my case? I noticed when you "Generate Database from Model" it recreates the entire schema from scratch which will obviously wipe all the data that is in the db. I was hoping for a more "Update Database from Model" approach where the db would just be altered to reflect the changes rather than recreated
View 1 Replies
Jun 14, 2010
I was just wondering if anyone has ever had to port the schema across? Are there any experts that could pitch their opinions on the achievability of this (mad) idea? I'm using the IBM Migration Toolkit and as expected its throwing a bunch of translation errors some of which were relatively easy to solve (vendor specific function calls for example) and some will take quite a while to pin down and work round.... however this is not my main concern.
If completed I expect I am going to have to basically rework all the System.Web.Profile/Roles/Membership namespace classes etc to work round the SQL limitations of informix (i.e. IDS11.x SQL server doesnt have a DEFAULT (newguid()) so that would have to be put into the calling method) (and any MVP comments really as I can slap my boss round with the weight after he ludicrously agreed to this project for a client without doing any research...)
View 1 Replies
Nov 18, 2010
I have made some changes to the markup in the default.aspx. It renders perfectly on my development server but doesn't render on the production. We are using ASP.Net 2.0.
I republished it serveral times but still not taking effect.
View 6 Replies
Jan 22, 2010
Creating a system with web front end and SQL backend (microsoft obviously). I have tried using the asp.netsqlprovider but i can;t as i am only allowed one database on the server, so i then tried to update my current database with the triggers to input the schema into the already existing database.Next step i create my own table with two simple fields of username and password and try and authenticate that way, i can't get that to work either.
I ahve limited permissions on the network as i am a University Student. I really don't know what to do. Never had to create a log on system before and i thought it would be far simpler than this. I ahve used Microsoft's sqlprovider schema before and it worked fine. I have also authenticated via IIS and AD too before. I can't do any of those two in this instance it seems.I need an alternative for logging in users, if needs be in can be crude. I also still need to have some kind of two different views too for logged in users and not logged in users, but that can change if needs must.Don't let me down people, haha. Think this posts in the correct place, i could not find another one i thought could be more relevant.
View 4 Replies
Sep 12, 2010
I'm using a windwos authentication via intranet. I'm able to display the username in a label control on a page load event (which is very simple).
I'm not storing this data anywhere in the table (MS SQL). I have all my data in a table and I'm using a gridview to diplay them. I'm using a button control to update all the rows in the gridview. I wanted to update three columns in the gridview (1. Tickbox, 2.Datetime Stamp and 3.UserId).
I've created a query in the dataset, through which i can update the Tickbox and DateTime stamp using now() function. But I'm not sure how to update the UserID field with the UserName (which inturn updates all the three fields in the gridview when the button is pressed.
View 2 Replies
Jul 23, 2010
I am using VS2008 and oracle 10g ODP.Net. The oracle database that I used in the connection is working and tested it using sql plus.The connection string when used in a GriDView works perfectly. Now when I created a new listview control with the same connection it gives an error.Database schema could not be retrieved for this connection. Please make sure connection settings are correct and the database is online
Object reference not set to an instance of an object at VSDataObjectSupport (478,6)
View 2 Replies
Feb 16, 2010
In my asp.net 2008 project, I am using the login controls... In the local sql server, there are all the necessary tables and stored procedures which the system creates for the relevant login controls. All working fine. I notice in the webconfig file there is an entry under connections, i.e.:
<add name="LocalSqlServer" connectionString="Data Source= ...
Now I would like to put the project into the Dev server. What do I do in terms
1- putting my web project into the Dev machine so that we can test it on the Dev server?
2- how do I put the login database schema into Dev? Is it just a matter of restoring my local DB into Dev?...
View 12 Replies
Mar 8, 2011
i am having a database in mysql and i want to use that database schema in my project using sql server. i have a Nhibernate c#do code generated by mysql. how can i use that code.
View 1 Replies
Nov 8, 2010
how to create schema like below for my database... and why it usefull
dbo.Employees.EmployeeNumber,
dbo.Employees.LastName + ', N' +
dbo.Employees.FirstName AS [Full Name],
dbo.Employees.HourlySalary,
dbo.TimeSheets.TimeSheetCode, dbo.TimeSheets.Week1Monday,
dbo.TimeSheets.Week1Tuesday, dbo.TimeSheets.Week1Wednesday,
dbo.TimeSheets.Week1Thursday, dbo.TimeSheets.Week1Friday,
dbo.TimeSheets.Week1Saturday, dbo.TimeSheets.Week1Sunday,
dbo.TimeSheets.Week2Monday, dbo.TimeSheets.Week2Tuesday,
dbo.TimeSheets.Week2Wednesday, dbo.TimeSheets.Week2Thursday,
dbo.TimeSheets.Week2Friday, dbo.TimeSheets.Week2Saturday,
dbo.TimeSheets.Week2Sunday
FROM dbo.Employees INNER JOIN dbo.TimeSheets
View 2 Replies
Jan 12, 2010
I have 3 different databases where some tables are common.
View 16 Replies
Jun 21, 2010
I'm using ASP.Net and NHibernate to build a website. Now, I need to add some sort of administration functionality, and came to think of an old django tutorial I once ran through. Here the admin page was build for me, and I could customize it as I liked. I see no reason that I couldn't accomplish the same, somehow, in ASP.Net, when I got my NHibernate schemas, thus reducing all the boilerplate admin-code I need to do. Are there any libs out there, that you think will fill my needs somehow?
View 1 Replies
Nov 18, 2010
I recently installed the latest Oracle Data Provider for .NET(ODP.NET 11.2.0.1.2), due to the fact that Microsoft Oracle Client is deprecated. Ever since the new installation, my SqlDataSource control stopped working. When I try to configure the data source of the SqlDataSource and test the connection, it always gives me the following error message:Database schema could not be retrieved for this connection. Please make sure the connection settings are correct and that the database is online.
OCIEnvCreate failed with return code -1 but error message text was not available. at DataObjectSupport(721,6)
I know for sure the connection settings are definitely correct and the database is online for sure, because any databinding I did manually works perfectly well. I can manually bind to a Gridview, ListBox controls and display the data without any problem. The only problem I have is using the SqlDataSource. This is painful because Gridview and Listview have a lot of cool built-in features. When you databind the controls in the code behind file, you lose all the features.
I have added ASPNET to the Oracle home directory and granted it full control access and retarted the computer but it doesn't work. I'm using Visual Studio 2010 and the database is Oracle 10g. Does anybody know why I'm having problem with SqlDataSource only?
View 1 Replies
Jan 7, 2010
I've created a Data Base project with some CLR functions and stored procedures.
I'd like to deploy the assembly under different schema then the default dbo.
Is it possible?
View 4 Replies
Apr 16, 2010
I have two databases. One from Oracle 10g. Another from Mysql. I have configured my web application with Nhibernate for Oracle and now I am in need of using the MySQL database. So how can i configure the hibernate.cfg.xml so that i can use both of the database at the same application?
My current hibernate.cfg.xml is:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>[code]......
View 1 Replies
Sep 9, 2010
what should be the database schema for online account opening form with joint account holders and every participants (in a joint account) have seperate contact and personal detials.
View 1 Replies
Jun 11, 2010
I am looking for a fast way (either by script or Query statements) that would enable me uniquely extract some tables from my database schema.
The tables I wish to extract have some unique columns like x and y coordinate columns and i want to extract only the tables that have these coulmns in them.
My database schema is very large with 100s of tables that i cant just go through the tables one by one.
View 4 Replies
Jan 4, 2011
This is related to a previous question I asked, regarding splitting a asp.net mvc web application into two apps - one public, and one admin. Both of them would be sharing the same database of course.
With two web apps I'll have two host applications and so two seperate Nihbernate session factories. My concern is that their seperate data caches will cause all sorts of problems.
While posting this, I looked at this question, which covers a similar problem (for a different reason). I really don't want to have to set up some kind of distributed cache just for a low use admin application.
How can this be resolved? Is separating the admin section into it's own application not possible with NHibernate without drastic measures?
View 2 Replies
Jan 11, 2011
I'm trying to build something like the MVC music store for learning purposes,
creating and deleting entries works great, but updating does not work -
for some reasoen after clicking the update button, i go back to the index page but no changes are saved.
I'v put a break point right before the SaveChanges(), i see that the form colection shows the new data, but it's not geting into the db?
View 12 Replies