Multiple database users, ORM, entity framework, best practices

Hello everyone!
You've already helped me several times, however I must ask for an advice once more.
I was assigned to develop .NET application with Data Access Layer and I've decided to use Oracle Database Software to provide sample data.
As I'm absolute novice considering creating DAL I'd be grateful if you can examine my plan in terms of security and reliability:
My database:
1) I've created database with sample tables and relations between them. All tables belongs to databaseAdmin.
2) I've created HR and Manager database users and granted them some privileges on certain databaseAdmin's tables. My intention is to reduce access to unnecessary tables. If my application user want to make some changes to Customers table it should be enough to connect to database as HR.
And now I'd like to map my database using Entity Framework in my application. And that's where I have a problem:
-If I create Entity Model basing on databaseAdmin tables I get perfect model, however every Entity SQL query would be executed on behalf of databaseAdmin, which breaks my idea of hiding unnecessary tables.
-If I create Entity Model for HR and Manager users, my models could overlap on tables that both users have access to and no connection between tables would be generated (as from their point of view those tables are just some tables that belong to databaseAdmin)
Could you help me with this deadlock? Or maybe my assumptions about multiple database users are incorrect? Please, bear in mind I'm a novice.
I was trying to find a solution in web, and there're tons of data discussing technical aspects of Entity Framework etc., but not so many documents about conceptual model of database.

hi Michael,
Thanks for you posting!
Sorry for I am not totally understanding your issue. Maybe two points need your confirm:
1. I confuse with the "Service controller"? IS your meaning MVC controller? Or ServiceController(http://www.codeproject.com/Articles/31688/Using-the-ServiceController-in-C-to-stop-and-start
2.whether  The type of ID in the model is match to the database ? In other words, Is the type of IDin .edmx matched to the database?
By the way, it seems that this issue is more related to EF. You could post this issue on EF discussion for better support.
Thanks & Regards,
Will
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • Seeding multiple databases with single Entity Framework context

    I am developing a single-instance, multi-tenant web application, with a SQL database using Entity Framework 6 Code-First. 
    I want to have a separate database for each client, generated from the same EF models, with a single DbContext. The database to connect to will be determined by the subdomain that the client is using the web app from. 
    This seems to work fine and the correct database is connected to depending on the subdomain. However my issue is seeding the databases with data. This is the code I have:
    foreach (var connString in ConfigurationManager.ConnectionStrings.Cast<ConnectionStringSettings>()))
    Configuration.PerformDatabaseMigration(connString.Name);
    This then calls the PerformDatabaseMigration method: 
    public class Configuration : DbMigrationsConfiguration<DataContext>
    public Configuration()
    AutomaticMigrationsEnabled = false;
    AutomaticMigrationDataLossAllowed = false;
    public static void PerformDatabaseMigration(string connStringName)
    var databaseInitialiser = new Configuration { TargetDatabase = new DbConnectionInfo(connStringName) };
    var dbMigrator = new DbMigrator(databaseInitialiser);
    dbMigrator.Update();
    protected override void Seed(DataContext context)
    base.Seed(context);
    var superAdmin = new User { Id = 1, UserName = "SuperAdmin" };
    context.Users.AddOrUpdate(superAdmin);
    The issue is that when seeding this data for the second database, the context passed into the Seed method already has the admin user added to the `DbSet<User>` property of the context, even though the context is for the second databse connection, not
    the first. It appears that the context is not being cleared from seeding the first database, and so I receive a `DbUpdateException`, as my User.Username field is a unique index.
    Cannot insert duplicate key row in object 'dbo.Users' with unique index 'IX_UserName'. The duplicate key value is (SuperAdmin).\r\nThe statement has been terminated.
    public class User : ModelBase, IUserIdentity, IPrincipal, IIdentity 
        [Index(IsUnique = true)]     
      [Required]     
      [StringLength(40)]       
    public string UserName { get; set; }

    Hello Attune,
    >>This seems to work fine and the correct database is connected to depending on the subdomain. However my issue is seeding the databases with data.
    Is that you firstly create these databases and then call the PerformDatabaseMigration method to seed these database with data? Do you have a try to seed these database data when creating the database with AutomaticMigrationsEnabled = true; with your provided
    configuration class, I tested it and it could work as seeding same data to different database:
    internal sealed class Configuration : DbMigrationsConfiguration<CFs.CFContext>
    public Configuration()
    AutomaticMigrationsEnabled = true;
    public static void PerformDatabaseMigration(string connStringName)
    var databaseInitialiser = new Configuration { TargetDatabase = new DbConnectionInfo(connStringName) };
    var dbMigrator = new DbMigrator(databaseInitialiser);
    dbMigrator.Update();
    protected override void Seed(CFs.CFContext context)
    base.Seed(context);
    var superAdmin = new ApplicationUser() { ApplicationUserID = 1, FirstName = "", LastName = "" };
    context.ApplicationUsers.AddOrUpdate(superAdmin);
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Update the database structure from entity Framework Model

    Hello !
    I'm using VB.net , EF6 with SQL server 2008R2 database.
    This is the situation :
    I have created the application. Using wizard I have created the Entity model from an existing database.
    A client start using this application using this database on his computer.
    After some month , I made some modifications on the database and I have updated the model on my application .
    Now I have a new .exe file that has the new model from the new database.
    I put the new .exe file on the client computer.
    Now on his computer : The .exe file has the new database model , but the sql server database has the old structure.
    I want to know : Is possible to update the database structure from the entity model on application ?
    I want to add a command on application that can make ( if is possible ) this update , so the database become up to date according to entity model ?
    Thank you !

    Hello,
    From your description, it seems that you want to apply a migration for a database first approach, unfortunately, as far as I know, EF Migrations is a product targeted at Code First and doesn't support Database First operations. A workaround I know is to
    use update-scripts. If your database structure would be changed frequently, it is recommended to use the Code First approach which would have a better workaround for migrations, for details, you could refer to this
    video,
     and with the
    Entity Framework Power Tools, it is easy to create a code first based project form an existing database.
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Multiple Database Pooling using Entity Bean

    Hi,
    Can anyone come across this problem? I have an entity bean (BMP). I want to connect to multiple databases(Oracle, My-SQL, MS-SQL Server). The application is like this. if a request come from the client i have to identify the client request and connect to the database. How to do this. How to connect to get the pool from the connection pooling. Please reply its urgent.
    thanks
    Prem

    Thanks for ur reply.
    what the point is i want to identify the client request and send this request to that bean. i have developed 30 cmp beans, if i have to identify i have to change all cmp to bmp, is there any solution to this.

  • Java Database User Role Privileges Framework

    Hello
    I am looking Java Framework which automatic generates Java Code for
    Database User Role Privileges Administration.
    Like in database we have a table of Users
    Now we have table of Author, Book etc. (Related to Library)
    Now i want to give insert permission to user1
    update and delete permission to user2 etc.
    Is there any framework related
    Remeber i do not need User Role Privileges in database.
    I need a framework to do this job.
    Thanks in Advance.

    There are tables created under the SAPSR3DB or SAP<SID>DB schema with extension .UME, such as SAPSR3DB.UME.ACL_ACL or SAPSR3DB.UME_ACL_ACLENTRY for AS-JAVA.
    There are other tables with the UME extension too.
    Regards,
    Anwar

  • Multiple Database Users

    Dear Experts
    I have created 3 database users (SCOTT, X, and Y). SCOTT user has all the database. I wanted to give the full rights to X and Y on the objects of SCOTT, so, I issued the command
    SQL>grant all on emp to X;
    Connecting X, i have to give schema.table_name to access data in EMP. Is there any way that i can extract data from SCOTT's object without using schema name with table or without creating synonyms.
    Regads

    user832095 wrote:
    I am extremly sorry,
    I am creating a duplicate server. The existing server has linux as os and oracle 10g db. All the users are created as database users and they can manipulate data through an application. I have a user dump, so, I restored data and created same users in new database and granted all the priviliges the are found in the existing db server, but I was getting user privileges error. I have checked the existibg server database thoroughly but i did not get sysnonyms there. I wonder how the users and their privileges are being maintained there. The same situation I have seen in Maximo database also.
    I am thankfull to my friends in this forum who gave me the valuable solutions. I hope if anybody can help me further
    Regards
    MASo exactly how did you create your "user dump"?
    And exactly How did you "restored data and created same users in new database"?
    And exactly what were you doing when you were "getting user privileges error"
    And what was the exact error message associated with "user privileges error"?
    It's really, really, really difficult (impossible, actually) to help when all you give us are vague descriptions of your interpretation of what you do and how oracle responds. There is no tax on using sqlplus and the fine copy and paste features available with most modern OS products.

  • One non-VPP app on multiple iPads -- what's the current best practice?

    So I've been playing around with Apple Configurator and think it has the potential to be useful in deploying multiple iPads (in this case, 18) to a client.  I've been able to configure one iPad, take a backup of it, and then easily deploy that backup to 2 iPads.  I've also been able to automatically install free apps... to a point.
    In this particular test I set up an old version of Pandora I had on my Mac to be installed on my test iPads.  I intentionally chose an old version of the app to see what would happen when it needed an update, assuming that it would ask for the personal iTunes account I originally used to download it.  And sure enough, my assumption was vindicated -- after this iPad was prepared by Apple Configurator, I went to the App Store, attempted to update Pandora, and was prompted to enter my personal iTunes account password.
    I figure that the next step would be to create an iTunes account specifically for downloading apps intended for deployment to clients, and I'm guessing I should just create individual iTunes accounts for each client, download the required apps, and configure each device to use that iTunes account.  But is this viable?  Is there some limit to how many devices you can associate with one iTunes account?  Is this really the best they could do?

    This is a challenge.  On our enterprise owned non-shared devices we ask the user, if they need to install apps that are non VPP, to use a personal iTunes account.  Though the devices are owned by the enterprise, and have enterprise security policies on them, we allow the users to put personal music photo's etc on them, and back them up on home, not work computers, with iTunes.  I think most users of non shared devices feel they are "personal" devices and treat them as such.  We do put an IPCU profile on them, and do require encryption through Exchange Server policies.  Shared devices, where 1 device might be used by a number of employees in one day (say in an Emergency Department for registrars), we associate with a enterprise created iTunes account that has the same name as the Exchange account used to attach the Exchange security policy to the device.  We use restrictions on these devices to block app purchases, safari etc.  In the case of the shared device, free apps would be installed by IT using the enterprise created iTunes account.  We are in the process of getting an MDM which we expect to simplify all of this.  My opinion ( for what it's worth) is that Apple is  becoming much more enterprise aware and is moving toward making the scenarios described easier to deal with.  iOS devices started as consumer centric devices but are being adopted in large numbers now by business, BYOD or otherwise. 

  • Storing user information into session best practice.

    I am developing an web application where user first have to login to be able to enter.
    When user correctly logged in an UserAccount object with all user data (except loginName and Password) is being stored into session. An Filter is checking session for UserAccount object and if user correctly logged in forwards the request to the next filter in the application.
    When user logged out, the session object is being destroyed. �Session invalidate()�
    I would like to know if there are better solutions for this.
    Thank you in advance.
    --Nermin B.

    You may want to also re-evaluate your "application" as a whole.
    In most cases - yours may be the exception - session objects are used to well, associate a particular web browser with a particular user. There usually is little need to retain additional information about that person, unless that information is frequently accessed. I think Shok used a poor example; a person's address, phone number, credit card number and so on is usually accessed once per visit, whereas the contents of that person's shopping cart is generally accessed every time the user changes web pages.
    The key concept here is you want to balance memory consumption verses database hits (or file i/o). Authorization info should be in the object, whereas general background info can be in the data source and accessed when needed.
    If on the other hand, you don't have a data source, you don't really have much of a choice and a session object (or similarly, a JavaBean) should just go ahead and contain all of the information about the user.
    To change the subject, session objects and JavaBeans are server side. As long as you keep a careful eye on the interfaces to those objects, you should be fine security wise. For example, if a person passes a parameter to your web page, make sure the parameter is anticipated and correct before you save it in the object. In other words, don't write a generic function that blindly accepts parameter names and values and sets them accordingly within the session object. The only place you should be able to set the password attribute is from the change-your-password JSP page.
    Cookies on the other hand are definitely stored on the client's machine, and yes, you want to be really paranoid and make sure that the cookie you are retrieving is the cookie you are expecting. I think the source of confusion is that session ids corresponding to session objects can be stored within a cookie - so you if can change the id, the server thinks you are someone else and uses that person's session object.

  • Using one user account table across multiple databases but account used as a foreign key

    I want to use one user account table from one database and use it across a couple other databases. The problem is that I want some tables to use the primary key from the user account table as a foreign key to access the data when the user logs in. Is this
    the right way of going about it? Do I have to create a user account table in all my databases? What is the best practice to handle this problem? Thanks in advance.

    You can use Triggers or using replication. 
    more info: 
    Add Foreign Key relationship between two Databases
    SQL Server Replication
    Saeid Hasani [sqldevelop]

  • MVC 4 Using Entity Framework How to save Images in Database

    Iam Beginner to
    MVC 4 ... I want to Upload Image from my form and save to the SQL Database by Using Entity Framework . I have searched alot but couldnt succeed yet,,

    http://forums.asp.net/
    You should post to the MVC section of above forum first.

  • Flex, PHP, MySQL Best Practices?

    When using the HTTPService to invoke PHP/ database
    transactions what are some best practices to insure multiple
    simultaneous users successfully complete the transaction?
    So, in my Actionscript I build an object to pass to the PHP
    script that uses the values of the object to build a SQL query and
    executes the query, evaluating the result.
    Right now, I'm returning a text string from the PHP script
    (after error checking there) that simply says "ok" if the script
    succeeded.. and using that string in the HTTPService.Result
    (lastResult) listener.
    Anyone have any experiences to comment on?
    thanks,
    Dan

    Or use AMFPHP and pass typed objects back and forth. I find
    this much easier than working with XML. Once you've used AMFPHP on
    one project, you'll wonder why you bothered with XML. Or at least
    that's how it was for me. AMFPHP 2.0 should be released very soon -
    I believe they're just getting the docs ready.
    Cheers,
    Darren.

  • Informatica and Essbase Best Practice questions

    We now have the Informatica adapter for Essbase installed and working. We have been able to get Informatica to upload data successfully. Now I have a few questions that I have not been able to find answers to in any documentation or forums for Informatica or Essbase. I have submitted these same questions to the Informatica Support but thought I would also post the questions here to see if many folks are using Informatica against Essbase.
    We are using:
    Informatica 8.6.1 (Linux)
    Essbase 11.1.1.3 (Windows 2003)
    1) I can see in Informtica that when we load data to Essbase (Target) it gives me the option to run a calc script AFTER it loads the data. However, if I need to run a Calc script BEFORE the load to Essbase (Target) what is the best practice? The work around I have found was to add the same session twice and for the 1st instance select the option to 'ONLY RUN THE CALC SCRIPT' on the mapping tab. The problem with this is the log shows that it will still run the query against the Source tables. This will impact run times and double to querying against the Source database. What is the Best Practice and proper way to build the workflow to Run a Calc Script BEFORE the load?
    2)Since you do not see the list of Calc Scripts for Essbase in Informatica (you have to manually type the Calc name), If I want to run the 'Default' calc for Essbase what is the syntax to run the 'Default' Calc Script? Tried 'Default' but didn't seem to work.
    3)I have other tasks in Essbase I want to do before actually having Informatica load the data. I would like to run the MAXL commands via a Command task. What is the Best Practice for doing this and the syntax to run MAXL commands in a Command Task in Informatica? I previously had Shell scripts built on the Informatica server that would be kicked off within Informatica, but we are trying to move away from shell scripts and instead have the scripting codes IN the workflows/sessions to make it easier to review the code and follow the logic, rather than having to find the scripts and open each of them.
    Any assistance you have with the two products working together I would GREATLY appreciate it!
    Robert

    AS i know addUser(User user){ ... } is much more useful for several reasons:
    1.Its object oriented
    2.its easy to write , because if Object has many parameters its very painful to write method with comma seperated parameters

  • Portal Design - Best Practices for Role and Workset Tab Menu

    We are looking to identify and promote best practices in SAP Portal Design. 
    First, is there a maximum number of tabs which should exist on the highest level tab menu, commonly called the role menu?  Do a large number of tabs on this menu cause performance issues?  Are there any other issues associated with a large number of tabs on this menu?
    Second, can the workset tab menu be customized to be 2 lines of tabs?  Our goal is to prevent tab scrolling.
    Thanks

    Debra,
    Not aware of any performance issues with the number of tabs in the Level 1 or 2 menus, particularly if you have portal navigation caching enabled.
    From an end user perspective I guess "best practice" would be to avoid scrolling in the top level navigation areas completely if possible.
    You can do a number of things to avoid this, including:
    - Keep the role/folder/workset names as short as possible.
    - If necessary break the role down into multiple level 1 entry points to reduce the number of tabs in level 2.
    An example of the second point would be MSS.  Instead of creating a role with a single workset (i.e. level 1 tab), we usually split it into two folders called something like "My Staff" and My Finance" and define these folders as entry points.  We therefore end up with two tabs in level 1 for the MSS role, and consequently a smaller number of tabs in level 2.
    Hope that helps......
    Regards,
    John

  • Portal build best practices

    Hello everyone,
    I'm soon starting a new WLP92 project and I would like to know which are the recommended best practices for building a portal project.
    I have experience with WLP8 projects that, frankly, wasn't easy to build.
    Is the following approach still valid?
    1 - export the Ant build using Workshop
    2 - customize the build if needed (test, etc.)
    Is anyone using continuous integration with Cruisecontrol?
    What about Maven2? Is anyone using the approach suggested on the dev2dev article ([url http://dev2dev.bea.com/pub/a/2007/03/maven-weblogic-portal.html])?
    This is quite a broad topic. It would be very interesting if we can use this thread to share common experience about build best practices.
    Thanks
    Luciano
    Edited by koevet at 07/29/2007 12:08 AM

    Debra,
    Not aware of any performance issues with the number of tabs in the Level 1 or 2 menus, particularly if you have portal navigation caching enabled.
    From an end user perspective I guess "best practice" would be to avoid scrolling in the top level navigation areas completely if possible.
    You can do a number of things to avoid this, including:
    - Keep the role/folder/workset names as short as possible.
    - If necessary break the role down into multiple level 1 entry points to reduce the number of tabs in level 2.
    An example of the second point would be MSS.  Instead of creating a role with a single workset (i.e. level 1 tab), we usually split it into two folders called something like "My Staff" and My Finance" and define these folders as entry points.  We therefore end up with two tabs in level 1 for the MSS role, and consequently a smaller number of tabs in level 2.
    Hope that helps......
    Regards,
    John

  • Best Practice to fetch SQL Server data and Insert into Oracle Tables

    Hello,
    I want to read sqlserver data everry half an hour and write into oracle tables ( in two different databases). What is the best practice for doing this?
    We do not have any database dblinks from oracle to sqlserver and vice versa.
    Any help is highly appreciable?
    Thanks

    Well, that's easy:
    use a TimerTask to do the following every half an hour:
    - open a connection to sql server
    - open two connections to the oracle databases
    - for each row you read from the sql server, do the inserts into the oracle databases
    - commit
    - close all connections

Maybe you are looking for