Base solution for your next web application
Open Closed

Urgent help in Migration issues #450


User avatar
0
sipoyraj created

Hello Team,

We are using Metronic (Asp.Net boilerplate) application, we are facing some challenges during MIGRATION. Below I am mentioning the challenges

  1. We have SQL Server environment, which is shared with many dot net developers. when one developer changes any table info(alter table) rest all get Migration errors.
  2. Once we added any Table in SQL Server, our entity framework will be adding some fields automatically **ref Note - a. Will it makes any problem in further ?
  3. There is a table called "Employee", it has 4 records of information. I just added one extra field to the table (any modification to the table). After migration from

the entity framework, in next moment all records is vanishing(truncating the table). we are loosing the entire data. We are unable to find out what mistake we are

doing... Reference attached image "Migration_Error"

  1. Debug is not catching in Application Service & ViewModel JS file (js file which located next to *.cshtml file). Totally unable to debug on runtime. on button click

button, simply its throwin to home(dashboard) page.

Note - a. [IsDeleted],[DeleterUserId],[DeletionTime],[LastModificationTime],[LastModifierUserId],[CreationTime],[CreatorUserId]

Please guide us to resolve all above issues.We are beginners of using all these stuffs. we need guidance for - I. How to reflect the table changes in sql server to entity framework II. We have separate class for calculation. Let assume, Class "Maths" which is have some public methods for Addition, Substraction, Multiply.... We would like to know

where (under which project) we need to add this business logic in our application. III. How and when to use migration or required ? IV. Do we need to mention any reference to the newly added sqlserver table in entity framework. Ref attached image "Entity_Framework"

Please provide any online help number or email or skype...

Thanks in advance.


1 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    These problems are related to your EntityFramework usage actually. But I will try to explain it as I can.

    First of all, AspNet Zero uses Entity Framework's CODE-FIRST Migrations. You should never make changes in SQL server tables by hand. Just change your model (entity classes), run "Add-Migration" command and then "Update-Database" command. Thus, your changes will be repeatable. I think you need to read some EF Code-First tutorials. Have you read this: <a class="postlink" href="http://www.aspnetzero.com/Documents/Developing-Step-By-Step">http://www.aspnetzero.com/Documents/Dev ... ep-By-Step</a> In this document, we describe how to create and change entities and database schema.

    For shared SQL Servers, it's always problematic to work (even you don't use code-first). My advice is to use local SQL Servers for each developer. If you should use shared, then follow this: One adds new migration (db change), update database, commit his code, inform others and all team gets latest version from source control.

    I definetely sugges to read this: <a class="postlink" href="https://msdn.microsoft.com/en-us/data/dn481501.aspx">https://msdn.microsoft.com/en-us/data/dn481501.aspx</a> (Code First Migrations in Team Environments) to understand code-first better.

    EF requires to add your Entities to DbContext. So, yes you should add your new entities to your DbContext class.

    You should normally add business (domain) logic to .Core project and Application logic into .Application project.

    Thanks.