Create bank automatically with Code First

-3

I'm creating an ASP.NET MVC application with Code First. This system is trade management software. I would separate the information from each company, and not leave everything in the same bank. We initially thought of leaving everything the same, but we thought about the performance issue. The bank would grow a lot, and it would take a few things.

I thought about creating the bank for the first login of that company, and then with the logged in user it could register the other users. He would be kind of the "master" of the company. Then the other users that he registered would go to a Logins bank where he would have a field that identified the company of that user, and accessed the bank of the same one. I would just create the bank for the first user of the company.

Is this possible?

    
asked by anonymous 22.01.2016 / 12:10

2 answers

2

This only makes sense if you have a deploy system per company. So I would have a company-by-system basis.

If the idea is to serve a single system for multiple companies, your idea just does not make sense. The high volume of data would only affect performance if you structure your wrong database, which is very difficult within the Entity Framework because it forces you to structure your database in the right way.

Either way, the correct way to do this is by putting this initial user in Migrations/Configuration.cs , Seed method. This is where initial insertions are made, such as bank users and minimum information from other entities.

In addition, structuring the database must take into account that information belonging to a company must be linked to a company entity. This is elementary modeling of the bank and you do not have to explain it in the answer. Already for access restrictions per company you find examples of how to do here .

    
22.01.2016 / 17:24
2

Using two dbContext would be simple, one for the business registration (accessing a fixed bank) and another for the specific bank of the company (dynamic bank), the second could read or create the ConnectionString based on the company registry. p>

The Master user would be registered together with the Companies and would be added to the specific bank in the Seed method.

When you log in, you choose the company and this directs which bank to connect to

    
10.03.2016 / 15:51